From 605a751571530693cc2d36bd41e4a3c11109678c Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 4 Sep 2025 13:13:58 +0200 Subject: [PATCH] InputText, InputInt, InputFloat: fixed an issue where using Escape to revert would not write back the reverted value. (#8915, #8273) Revealed by 00f12b9a0 Regression test: "widgets_inputtext_temp_buffer_2" --- docs/CHANGELOG.txt | 4 ++++ imgui.h | 2 +- imgui_widgets.cpp | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 479115613..172e2f5cc 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -55,6 +55,10 @@ Other Changes: - Nav: fixed Ctrl+Tab window appearing as empty when the sole active and focused window has the ImGuiWindowFlags_NoNavFocus flag. (#8914) - Bullet: fixed tesselation amount which looked out of place in very large sizes. +- InputText, InputInt, InputFloat: fixed an issue where using Escape to revert + would not write back the reverted value during the IsItemDeactivatedAfterEdit() + frame if the provided input buffer doesn't store temporary edits. + (regression in 1.91.7) (#8915, #8273) - InputText: allow passing an empty string with buf_size==0. (#8907) In theory the buffer size should always account for a zero-terminator, but idioms such as using InputTextMultiline() with ImGuiInputTextFlags_ReadOnly to display diff --git a/imgui.h b/imgui.h index 859cb0318..cee72416c 100644 --- a/imgui.h +++ b/imgui.h @@ -29,7 +29,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') #define IMGUI_VERSION "1.92.3 WIP" -#define IMGUI_VERSION_NUM 19224 +#define IMGUI_VERSION_NUM 19225 #define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000 #define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198 diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 3012404e0..1d6fc9a83 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -5058,14 +5058,14 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ if (flags & ImGuiInputTextFlags_EscapeClearsAll) { // Clear input - IM_ASSERT(buf[0] != 0); + IM_ASSERT(buf[0] != 0); // FIXME: use TextA here? apply_new_text = ""; apply_new_text_length = 0; value_changed = true; IMSTB_TEXTEDIT_CHARTYPE empty_string; stb_textedit_replace(state, state->Stb, &empty_string, 0); } - else if (strcmp(buf, state->TextToRevertTo.Data) != 0) + else if (strcmp(state->TextA.Data, state->TextToRevertTo.Data) != 0) { apply_new_text = state->TextToRevertTo.Data; apply_new_text_length = state->TextToRevertTo.Size - 1;