InputText: Fixed returning true when edition is cancelled with Esc and the current buffer matches the initial value.

This commit is contained in:
omar 2018-04-27 17:19:49 +02:00
parent 28edece04f
commit 101f9b42b7
2 changed files with 3 additions and 2 deletions

View File

@ -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] - 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, 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: 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) - 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) - 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. - Demo: Fixed Overlay: Added a context menu item to enable freely moving the window.

View File

@ -10245,8 +10245,8 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
{ {
if (cancel_edit) if (cancel_edit)
{ {
// Restore initial value // Restore initial value. Only return true if restoring to the initial value changes the current buffer contents.
if (is_editable) if (is_editable && strncmp(buf, edit_state.InitialText.Data, buf_size) != 0)
{ {
ImStrncpy(buf, edit_state.InitialText.Data, buf_size); ImStrncpy(buf, edit_state.InitialText.Data, buf_size);
value_changed = true; value_changed = true;