mirror of
https://github.com/ocornut/imgui.git
synced 2026-05-30 13:55:24 +08:00
InputInt, InputFloat, InputScalar: reinstated and fixed ImGuiInputTextFlags_EnterReturnsTrue. (#8665, #9299, #8065, #3946, #6284, #9117)
This commit is contained in:
@@ -89,6 +89,14 @@ Other Changes:
|
|||||||
- Detect and report error when calling End() instead of EndPopup() on a popup. (#9351)
|
- Detect and report error when calling End() instead of EndPopup() on a popup. (#9351)
|
||||||
- Child windows with only ImGuiChildFlags_AutoResizeY flag keep using the proportional
|
- Child windows with only ImGuiChildFlags_AutoResizeY flag keep using the proportional
|
||||||
default ItemWidth. (#9355)
|
default ItemWidth. (#9355)
|
||||||
|
- InputInt, InputFloat, InputScalar: reinstated ImGuiInputTextFlags_EnterReturnsTrue
|
||||||
|
support which was removed in 1.91.4. (#8665, #9299, #8065, #3946, #6284, #9117)
|
||||||
|
- Fixed the fact that it didn't return true when validating same value.
|
||||||
|
- Fixed losing value when tabbing out or losing focus.
|
||||||
|
- Made it that pressing +/- step buttons also return true, which is in line
|
||||||
|
with 1.91.4 behavior.
|
||||||
|
- In a majority of cases you should use IsItemDeactivatedAfterEdit() instead,
|
||||||
|
but it still has a few edge cases flaws (to be addressed soon).
|
||||||
- Multi-Select:
|
- Multi-Select:
|
||||||
- Fixed an issue using Multi-Select within a Table causing column width measurement to
|
- Fixed an issue using Multi-Select within a Table causing column width measurement to
|
||||||
be invalid when trailing column contents is not submitted in the last row. (#9341, #8250)
|
be invalid when trailing column contents is not submitted in the last row. (#9341, #8250)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
// Library Version
|
// Library Version
|
||||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
|
||||||
#define IMGUI_VERSION "1.92.8 WIP"
|
#define IMGUI_VERSION "1.92.8 WIP"
|
||||||
#define IMGUI_VERSION_NUM 19274
|
#define IMGUI_VERSION_NUM 19275
|
||||||
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
|
||||||
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198
|
||||||
|
|
||||||
|
|||||||
+7
-4
@@ -3795,7 +3795,7 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
|||||||
|
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiStyle& style = g.Style;
|
ImGuiStyle& style = g.Style;
|
||||||
IM_ASSERT((flags & ImGuiInputTextFlags_EnterReturnsTrue) == 0); // Not supported by InputScalar(). Please open an issue if you this would be useful to you. Otherwise use IsItemDeactivatedAfterEdit()!
|
//IM_ASSERT((flags & ImGuiInputTextFlags_EnterReturnsTrue) == 0); // Not supported by InputScalar(). Please open an issue if you this would be useful to you. Otherwise use IsItemDeactivatedAfterEdit()!
|
||||||
|
|
||||||
if (format == NULL)
|
if (format == NULL)
|
||||||
format = DataTypeGetInfo(data_type)->PrintFmt;
|
format = DataTypeGetInfo(data_type)->PrintFmt;
|
||||||
@@ -3832,7 +3832,8 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply
|
// Apply
|
||||||
bool value_changed = ret ? DataTypeApplyFromText(buf, data_type, p_data, format, (flags & ImGuiInputTextFlags_ParseEmptyRefVal) ? p_data_default : NULL) : false;
|
bool input_edited = (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_EditedInternal) != 0; // We would be using 'ret' if ImGuiInputTextFlags_EnterReturnsTrue was not involved.
|
||||||
|
bool value_changed = input_edited ? DataTypeApplyFromText(buf, data_type, p_data, format, (flags & ImGuiInputTextFlags_ParseEmptyRefVal) ? p_data_default : NULL) : false;
|
||||||
|
|
||||||
// Step buttons
|
// Step buttons
|
||||||
if (has_step_buttons)
|
if (has_step_buttons)
|
||||||
@@ -3846,13 +3847,13 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
|||||||
if (ButtonEx("-", ImVec2(button_size, button_size)))
|
if (ButtonEx("-", ImVec2(button_size, button_size)))
|
||||||
{
|
{
|
||||||
DataTypeApplyOp(data_type, '-', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
|
DataTypeApplyOp(data_type, '-', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
|
||||||
value_changed = true;
|
value_changed = ret = true;
|
||||||
}
|
}
|
||||||
SameLine(0, style.ItemInnerSpacing.x);
|
SameLine(0, style.ItemInnerSpacing.x);
|
||||||
if (ButtonEx("+", ImVec2(button_size, button_size)))
|
if (ButtonEx("+", ImVec2(button_size, button_size)))
|
||||||
{
|
{
|
||||||
DataTypeApplyOp(data_type, '+', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
|
DataTypeApplyOp(data_type, '+', p_data, p_data, g.IO.KeyCtrl && p_step_fast ? p_step_fast : p_step);
|
||||||
value_changed = true;
|
value_changed = ret = true;
|
||||||
}
|
}
|
||||||
PopItemFlag();
|
PopItemFlag();
|
||||||
if (flags & ImGuiInputTextFlags_ReadOnly)
|
if (flags & ImGuiInputTextFlags_ReadOnly)
|
||||||
@@ -3874,6 +3875,8 @@ bool ImGui::InputScalar(const char* label, ImGuiDataType data_type, void* p_data
|
|||||||
if (value_changed)
|
if (value_changed)
|
||||||
MarkItemEdited(g.LastItemData.ID);
|
MarkItemEdited(g.LastItemData.ID);
|
||||||
|
|
||||||
|
if (flags & ImGuiInputTextFlags_EnterReturnsTrue)
|
||||||
|
return ret;
|
||||||
return value_changed;
|
return value_changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user