mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-27 17:10:57 +01:00
Drags, Sliders, Inputs: removed all attempts to filter non-numerical characters during text editing. (#6810, #7096)
This commit is contained in:
parent
f039e69b9c
commit
4a2426449a
@ -70,6 +70,8 @@ Other changes:
|
||||
- InputTextMultiline: Tabbing through a multi-line text editor which allows Tab character inputs
|
||||
(using the ImGuiInputTextFlags_AllowTabInput flag) doesn't automatically activate it, in order
|
||||
to allow passing through multiple widgets easily. (#3092, #5759, #787)
|
||||
- Drags, Sliders, Inputs: removed all attempts to filter non-numerical characters during text
|
||||
editing. Invalid inputs not applied to value, visibly reverted after validation. (#6810, #7096)
|
||||
- DragScalarN, SliderScalarN, InputScalarN, PushMultiItemsWidths: improve multi-components
|
||||
width computation to better distribute the error. (#7120, #7121) [@Nahor]
|
||||
- ColorEdit4: Layout tweaks for very small sizes. (#7120, #7121)
|
||||
|
@ -3395,14 +3395,6 @@ bool ImGui::TempInputText(const ImRect& bb, ImGuiID id, const char* label, char*
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
static inline ImGuiInputTextFlags InputScalar_DefaultCharsFilter(ImGuiDataType data_type, const char* format)
|
||||
{
|
||||
if (data_type == ImGuiDataType_Float || data_type == ImGuiDataType_Double)
|
||||
return ImGuiInputTextFlags_CharsScientific;
|
||||
const char format_last_char = format[0] ? format[strlen(format) - 1] : 0;
|
||||
return (format_last_char == 'x' || format_last_char == 'X') ? ImGuiInputTextFlags_CharsHexadecimal : ImGuiInputTextFlags_CharsDecimal;
|
||||
}
|
||||
|
||||
// Note that Drag/Slider functions are only forwarding the min/max values clamping values if the ImGuiSliderFlags_AlwaysClamp flag is set!
|
||||
// This is intended: this way we allow CTRL+Click manual input to set a value out of bounds, for maximum flexibility.
|
||||
// However this may not be ideal for all uses, as some user code may break on out of bound values.
|
||||
@ -3420,7 +3412,6 @@ bool ImGui::TempInputScalar(const ImRect& bb, ImGuiID id, const char* label, ImG
|
||||
ImStrTrimBlanks(data_buf);
|
||||
|
||||
ImGuiInputTextFlags flags = ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited;
|
||||
flags |= InputScalar_DefaultCharsFilter(data_type, format);
|
||||
|
||||
bool value_changed = false;
|
||||
if (TempInputText(bb, id, label, data_buf, IM_ARRAYSIZE(data_buf), flags))
|
||||
@ -3464,9 +3455,6 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
||||
char buf[64];
|
||||
DataTypeFormatString(buf, IM_ARRAYSIZE(buf), data_type, p_data, format);
|
||||
|
||||
// Testing ActiveId as a minor optimization as filtering is not needed until active
|
||||
if (g.ActiveId == 0 && (flags & (ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsScientific)) == 0)
|
||||
flags |= InputScalar_DefaultCharsFilter(data_type, format);
|
||||
flags |= ImGuiInputTextFlags_AutoSelectAll | (ImGuiInputTextFlags)ImGuiInputTextFlags_NoMarkEdited; // We call MarkItemEdited() ourselves by comparing the actual data rather than the string.
|
||||
|
||||
bool value_changed = false;
|
||||
@ -3561,7 +3549,6 @@ bool ImGui::InputScalarN(const char* label, ImGuiDataType data_type, void* p_dat
|
||||
|
||||
bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast, const char* format, ImGuiInputTextFlags flags)
|
||||
{
|
||||
flags |= ImGuiInputTextFlags_CharsScientific;
|
||||
return InputScalar(label, ImGuiDataType_Float, (void*)v, (void*)(step > 0.0f ? &step : NULL), (void*)(step_fast > 0.0f ? &step_fast : NULL), format, flags);
|
||||
}
|
||||
|
||||
@ -3604,7 +3591,6 @@ bool ImGui::InputInt4(const char* label, int v[4], ImGuiInputTextFlags flags)
|
||||
|
||||
bool ImGui::InputDouble(const char* label, double* v, double step, double step_fast, const char* format, ImGuiInputTextFlags flags)
|
||||
{
|
||||
flags |= ImGuiInputTextFlags_CharsScientific;
|
||||
return InputScalar(label, ImGuiDataType_Double, (void*)v, (void*)(step > 0.0 ? &step : NULL), (void*)(step_fast > 0.0 ? &step_fast : NULL), format, flags);
|
||||
}
|
||||
|
||||
@ -5238,7 +5224,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag
|
||||
else
|
||||
ImFormatString(buf, IM_ARRAYSIZE(buf), "#%02X%02X%02X", ImClamp(i[0], 0, 255), ImClamp(i[1], 0, 255), ImClamp(i[2], 0, 255));
|
||||
SetNextItemWidth(w_inputs);
|
||||
if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsHexadecimal | ImGuiInputTextFlags_CharsUppercase))
|
||||
if (InputText("##Text", buf, IM_ARRAYSIZE(buf), ImGuiInputTextFlags_CharsUppercase))
|
||||
{
|
||||
value_changed = true;
|
||||
char* p = buf;
|
||||
|
Loading…
Reference in New Issue
Block a user