|
|
@ -122,7 +122,7 @@ static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1); |
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// For InputTextEx()
|
|
|
|
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, ImGuiInputSource input_source); |
|
|
|
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, bool input_source_is_clipboard = false); |
|
|
|
static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end); |
|
|
|
static ImVec2 InputTextCalcTextSizeW(ImGuiContext* ctx, const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL, ImVec2* out_offset = NULL, bool stop_on_new_line = false); |
|
|
|
|
|
|
@ -3916,9 +3916,8 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons |
|
|
|
} |
|
|
|
|
|
|
|
// Return false to discard a character.
|
|
|
|
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, ImGuiInputSource input_source) |
|
|
|
static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, bool input_source_is_clipboard) |
|
|
|
{ |
|
|
|
IM_ASSERT(input_source == ImGuiInputSource_Keyboard || input_source == ImGuiInputSource_Clipboard); |
|
|
|
unsigned int c = *p_char; |
|
|
|
|
|
|
|
// Filter non-printable (NB: isprint is unreliable! see #2467)
|
|
|
@ -3933,7 +3932,7 @@ static bool InputTextFilterCharacter(ImGuiContext* ctx, unsigned int* p_char, Im |
|
|
|
apply_named_filters = false; // Override named filters below so newline and tabs can still be inserted.
|
|
|
|
} |
|
|
|
|
|
|
|
if (input_source != ImGuiInputSource_Clipboard) |
|
|
|
if (input_source_is_clipboard == false) |
|
|
|
{ |
|
|
|
// We ignore Ascii representation of delete (emitted from Backspace on OSX, see #2578, #2817)
|
|
|
|
if (c == 127) |
|
|
@ -4418,7 +4417,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ |
|
|
|
if (Shortcut(ImGuiKey_Tab, id, ImGuiInputFlags_Repeat)) |
|
|
|
{ |
|
|
|
unsigned int c = '\t'; // Insert TAB
|
|
|
|
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard)) |
|
|
|
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data)) |
|
|
|
state->OnKeyPressed((int)c); |
|
|
|
} |
|
|
|
// FIXME: Implement Shift+Tab
|
|
|
@ -4441,7 +4440,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ |
|
|
|
unsigned int c = (unsigned int)io.InputQueueCharacters[n]; |
|
|
|
if (c == '\t') // Skip Tab, see above.
|
|
|
|
continue; |
|
|
|
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard)) |
|
|
|
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data)) |
|
|
|
state->OnKeyPressed((int)c); |
|
|
|
} |
|
|
|
|
|
|
@ -4524,7 +4523,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ |
|
|
|
else if (!is_readonly) |
|
|
|
{ |
|
|
|
unsigned int c = '\n'; // Insert new line
|
|
|
|
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard)) |
|
|
|
if (InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data)) |
|
|
|
state->OnKeyPressed((int)c); |
|
|
|
} |
|
|
|
} |
|
|
@ -4591,7 +4590,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ |
|
|
|
{ |
|
|
|
unsigned int c; |
|
|
|
s += ImTextCharFromUtf8(&c, s, NULL); |
|
|
|
if (!InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data, ImGuiInputSource_Clipboard)) |
|
|
|
if (!InputTextFilterCharacter(&g, &c, flags, callback, callback_user_data, true)) |
|
|
|
continue; |
|
|
|
clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c; |
|
|
|
} |
|
|
|