Skip to content

Commit

Permalink
InputText: Fix named filtering flags disabling newline or tabs in mul…
Browse files Browse the repository at this point in the history
…tiline inputs (#4409, #4410)
  • Loading branch information
kfsone authored and ocornut committed Aug 17, 2021
1 parent b380d3a commit 7e9e1ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3842,13 +3842,15 @@ 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;
pass |= (c == '\n' && (flags & ImGuiInputTextFlags_Multiline));
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)
Expand All @@ -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 '.'.
Expand Down

0 comments on commit 7e9e1ff

Please sign in to comment.