|
|
|
@ -3923,6 +3923,13 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f |
|
|
|
|
ImGuiContext& g = *GImGui; |
|
|
|
|
const unsigned c_decimal_point = (unsigned int)g.PlatformLocaleDecimalPoint; |
|
|
|
|
|
|
|
|
|
// Full-width -> half-width conversion for numeric fields (https://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms_(Unicode_block)
|
|
|
|
|
// While this is mostly convenient, this has the side-effect for uninformed users accidentally inputting full-width characters that they may
|
|
|
|
|
// scratch their head as to why it works in numerical fields vs in generic text fields it would require support in the font.
|
|
|
|
|
if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsScientific | ImGuiInputTextFlags_CharsHexadecimal)) |
|
|
|
|
if (c >= 0xFF01 && c <= 0xFF5E) |
|
|
|
|
c = c - 0xFF01 + 0x21; |
|
|
|
|
|
|
|
|
|
// Allow 0-9 . - + * /
|
|
|
|
|
if (flags & ImGuiInputTextFlags_CharsDecimal) |
|
|
|
|
if (!(c >= '0' && c <= '9') && (c != c_decimal_point) && (c != '-') && (c != '+') && (c != '*') && (c != '/')) |
|
|
|
@ -3941,11 +3948,13 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f |
|
|
|
|
// Turn a-z into A-Z
|
|
|
|
|
if (flags & ImGuiInputTextFlags_CharsUppercase) |
|
|
|
|
if (c >= 'a' && c <= 'z') |
|
|
|
|
*p_char = (c += (unsigned int)('A' - 'a')); |
|
|
|
|
c += (unsigned int)('A' - 'a'); |
|
|
|
|
|
|
|
|
|
if (flags & ImGuiInputTextFlags_CharsNoBlank) |
|
|
|
|
if (ImCharIsBlankW(c)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
*p_char = c; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Custom callback filter
|
|
|
|
|