From 101f9b42b73caf3476c622bb48d4a544242121ad Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 27 Apr 2018 17:19:49 +0200 Subject: [PATCH] InputText: Fixed returning true when edition is cancelled with Esc and the current buffer matches the initial value. --- CHANGELOG.txt | 1 + imgui.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 8af43b8c7..896dd3726 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -56,6 +56,7 @@ Other Changes: - MenuBar: Made BeginMainMenuBar() honor style.DisplaySafeAreaPadding so the text can be made visible on TV settings that don't display all pixels. (#1439) [@dougbinks] - InputText: On Mac OS X, filter out characters when the Cmd modifier is held. (#1747) [@sivu] - InputText: On Mac OS X, support Cmd+Shift+Z for Redo. Cmd+Y is also supported as major apps seems to default to support both. (#1765) [@lfnoise] +- InputText: Fixed returning true when edition is cancelled with Esc and the current buffer matches the initial value. - Style: Changed default style.DisplaySafeAreaPadding values from (4,4) to (3,3) so it is smaller than FramePadding and has no effect on main menu bar on a computer. (#1439) - Misc: Added IMGUI_CHECKVERSION() macro to compare version string and data structure sizes in order to catch issues with mismatching compilation unit settings. (#1695, #1769) - Demo: Fixed Overlay: Added a context menu item to enable freely moving the window. diff --git a/imgui.cpp b/imgui.cpp index 033bfe899..59faabb3d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -10245,8 +10245,8 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2 { if (cancel_edit) { - // Restore initial value - if (is_editable) + // Restore initial value. Only return true if restoring to the initial value changes the current buffer contents. + if (is_editable && strncmp(buf, edit_state.InitialText.Data, buf_size) != 0) { ImStrncpy(buf, edit_state.InitialText.Data, buf_size); value_changed = true;