From a1a7a1bc037b23477dd469c82f1d7590f4fb10cf Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 17 Aug 2023 13:02:56 +0200 Subject: [PATCH] InputFloat, SliderFloat, DragFloat: always turn both '.' and ',' into the current decimal point character. (#6719, #2278) --- docs/CHANGELOG.txt | 2 ++ imgui_widgets.cpp | 3 +++ 2 files changed, 5 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 8deebc49ead6..3f45d774948b 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -50,6 +50,8 @@ Other changes: through proper navigation logic: honor scrolling and selection. (#1079, #1131) - Sliders: Fixed an integer overflow and div-by-zero in SliderInt() when v_max=INT_MAX (#6675, #6679) [@jbarthelmes] +- InputFloat, SliderFloat, DragFloat: always turn both '.' and ',' into the current decimal + point character when using Decimal/Scientific character filter. (#6719, #2278) [@adamsepp] - ImDrawData: Fixed an issue where TotalVtxCount/TotalIdxCount does not match the sum of individual ImDrawList's buffer sizes when a dimming/modal background is rendered. (#6716) - ImDrawList: Fixed OOB access in _CalcCircleAutoSegmentCount when passing excessively diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index e5b9c06107ed..ddf652152e10 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -3948,6 +3948,9 @@ static bool InputTextFilterCharacter(unsigned int* p_char, ImGuiInputTextFlags f // Users of non-default decimal point (in particular ',') may be affected by word-selection logic (is_word_boundary_from_right/is_word_boundary_from_left) functions. ImGuiContext& g = *GImGui; const unsigned c_decimal_point = (unsigned int)g.PlatformLocaleDecimalPoint; + if (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsScientific)) + if (c == '.' || c == ',') + c = c_decimal_point; // 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