|
|
@ -122,7 +122,7 @@ static const ImU64 IM_U64_MAX = (2ULL * 9223372036854775807LL + 1); |
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// For InputTextEx()
|
|
|
|
static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data); |
|
|
|
static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, ImGuiInputSource input_source); |
|
|
|
static int InputTextCalcTextLenAndLineCount(const char* text_begin, const char** out_text_end); |
|
|
|
static ImVec2 InputTextCalcTextSizeW(const ImWchar* text_begin, const ImWchar* text_end, const ImWchar** remaining = NULL, ImVec2* out_offset = NULL, bool stop_on_new_line = false); |
|
|
|
|
|
|
@ -3764,8 +3764,9 @@ void ImGuiInputTextCallbackData::InsertChars(int pos, const char* new_text, cons |
|
|
|
} |
|
|
|
|
|
|
|
// Return false to discard a character.
|
|
|
|
static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) |
|
|
|
static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data, ImGuiInputSource input_source) |
|
|
|
{ |
|
|
|
IM_ASSERT(input_source == ImGuiInputSource_Keyboard || input_source == ImGuiInputSource_Clipboard); |
|
|
|
unsigned int c = *p_char; |
|
|
|
|
|
|
|
// Filter non-printable (NB: isprint is unreliable! see #2467)
|
|
|
@ -3778,15 +3779,18 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// We ignore Ascii representation of delete (emitted from Backspace on OSX, see #2578, #2817)
|
|
|
|
if (c == 127) |
|
|
|
return false; |
|
|
|
if (input_source != ImGuiInputSource_Clipboard) |
|
|
|
{ |
|
|
|
// We ignore Ascii representation of delete (emitted from Backspace on OSX, see #2578, #2817)
|
|
|
|
if (c == 127) |
|
|
|
return false; |
|
|
|
|
|
|
|
// Filter private Unicode range. GLFW on OSX seems to send private characters for special keys like arrow keys (FIXME)
|
|
|
|
if (c >= 0xE000 && c <= 0xF8FF) |
|
|
|
return false; |
|
|
|
// Filter private Unicode range. GLFW on OSX seems to send private characters for special keys like arrow keys (FIXME)
|
|
|
|
if (c >= 0xE000 && c <= 0xF8FF) |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
// Filter Unicode ranges we are not handling in this build.
|
|
|
|
// Filter Unicode ranges we are not handling in this build
|
|
|
|
if (c > IM_UNICODE_CODEPOINT_MAX) |
|
|
|
return false; |
|
|
|
|
|
|
@ -4111,7 +4115,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ |
|
|
|
if (!io.InputQueueCharacters.contains('\t')) |
|
|
|
{ |
|
|
|
unsigned int c = '\t'; // Insert TAB
|
|
|
|
if (InputTextFilterCharacter(&c, flags, callback, callback_user_data)) |
|
|
|
if (InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard)) |
|
|
|
state->OnKeyPressed((int)c); |
|
|
|
} |
|
|
|
|
|
|
@ -4126,7 +4130,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' && io.KeyShift) |
|
|
|
continue; |
|
|
|
if (InputTextFilterCharacter(&c, flags, callback, callback_user_data)) |
|
|
|
if (InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard)) |
|
|
|
state->OnKeyPressed((int)c); |
|
|
|
} |
|
|
|
|
|
|
@ -4190,7 +4194,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(&c, flags, callback, callback_user_data)) |
|
|
|
if (InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Keyboard)) |
|
|
|
state->OnKeyPressed((int)c); |
|
|
|
} |
|
|
|
} |
|
|
@ -4243,7 +4247,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ |
|
|
|
s += ImTextCharFromUtf8(&c, s, NULL); |
|
|
|
if (c == 0) |
|
|
|
break; |
|
|
|
if (!InputTextFilterCharacter(&c, flags, callback, callback_user_data)) |
|
|
|
if (!InputTextFilterCharacter(&c, flags, callback, callback_user_data, ImGuiInputSource_Clipboard)) |
|
|
|
continue; |
|
|
|
clipboard_filtered[clipboard_filtered_len++] = (ImWchar)c; |
|
|
|
} |
|
|
|