Skip to content

Commit

Permalink
Implements ocornut#4409
Browse files Browse the repository at this point in the history
  • Loading branch information
kfsone committed Aug 14, 2021
1 parent c7529c8 commit bb49d1c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3841,6 +3841,8 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f
IM_ASSERT(input_source == ImGuiInputSource_Keyboard || input_source == ImGuiInputSource_Clipboard);
unsigned int c = *p_char;

bool apply_named_filters = flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase | ImGuiInputTextFlags_CharsNoBlank | ImGuiInputTextFlags_CharsScientific);

// Filter non-printable (NB: isprint is unreliable! see #2467)
if (c < 0x20)
{
Expand All @@ -3849,6 +3851,9 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f
pass |= (c == '\t' && (flags & ImGuiInputTextFlags_AllowTabInput));
if (!pass)
return false;

// Allow input text flags to override named filter behaviors for tab and newline.
apply_named_filters = false;
}

if (input_source != ImGuiInputSource_Clipboard)
Expand All @@ -3867,7 +3872,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)
{
// 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 bb49d1c

Please sign in to comment.