From 7e9e1ff1c29aebfd8f98dd4fdc8648131ef28c5a Mon Sep 17 00:00:00 2001 From: Oliver 'kfsone' Smith Date: Sat, 7 Aug 2021 19:25:26 -0700 Subject: [PATCH] InputText: Fix named filtering flags disabling newline or tabs in multiline inputs (#4409, #4410) --- docs/CHANGELOG.txt | 1 + imgui_widgets.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index f2fa0876d..59a726a4b 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -68,6 +68,7 @@ Other Changes: - Tables: Fix invalid data in TableGetSortSpecs() when SpecsDirty flag is unset. (#4233) - TabBar: Fixed using more than 32 KB-worth of tab names. (#4176) - InputInt/InputFloat: When used with Steps values and _ReadOnly flag, the step button look disabled. (#211) +- InputText: Fixed named filtering flags disabling newline or tabs in multiline inputs (#4409, #4410) [@kfsone] - Drag and Drop: drop target highlight doesn't try to bypass host clipping rectangle. (#4281, #3272) - Menus: MenuItem() and BeginMenu() are not affected/overlapping when style.SelectableTextAlign is altered. - Menus: fix hovering a disabled menu or menu item not closing other menus. (#211) diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 699fdc70c..9716db6b3 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -3842,6 +3842,7 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f unsigned int c = *p_char; // Filter non-printable (NB: isprint is unreliable! see #2467) + bool apply_named_filters = true; if (c < 0x20) { bool pass = false; @@ -3849,6 +3850,7 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f pass |= (c == '\t' && (flags & ImGuiInputTextFlags_AllowTabInput)); if (!pass) return false; + apply_named_filters = false; // Override named filters below so newline and tabs can still be inserted. } if (input_source != ImGuiInputSource_Clipboard) @@ -3867,7 +3869,7 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f return false; // Generic named filters - if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific)) + if (apply_named_filters && (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific))) { // The libc allows overriding locale, with e.g. 'setlocale(LC_NUMERIC, "de_DE.UTF-8");' which affect the output/input of printf/scanf. // The standard mandate that programs starts in the "C" locale where the decimal point is '.'.