Pārlūkot izejas kodu

InputText: fixed an issue where using Escape with ImGuiInputTextFlags_EscapeClearsAll. (#8915, #8273)

Regression test: "widgets_inputtext_temp_buffer_2"
ocornut 1 nedēļu atpakaļ
vecāks
revīzija
7d33524042
2 mainītis faili ar 5 papildinājumiem un 2 dzēšanām
  1. 3 0
      docs/CHANGELOG.txt
  2. 2 2
      imgui_widgets.cpp

+ 3 - 0
docs/CHANGELOG.txt

@@ -59,6 +59,9 @@ Other Changes:
   would not write back the reverted value during the IsItemDeactivatedAfterEdit()
   would not write back the reverted value during the IsItemDeactivatedAfterEdit()
   frame if the provided input buffer doesn't store temporary edits.
   frame if the provided input buffer doesn't store temporary edits.
   (regression in 1.91.7) (#8915, #8273)
   (regression in 1.91.7) (#8915, #8273)
+- InputText: fixed an issue where using Escape with ImGuiInputTextFlags_EscapeClearsAll
+  would not write back the cleared value during the IsItemDeactivatedAfterEdit()
+  frame if the provided input buffer doesn't store temporary edits. (#8915, #8273)
 - InputText: allow passing an empty string with buf_size==0. (#8907)
 - 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
   In theory the buffer size should always account for a zero-terminator, but idioms
   such as using InputTextMultiline() with ImGuiInputTextFlags_ReadOnly to display
   such as using InputTextMultiline() with ImGuiInputTextFlags_ReadOnly to display

+ 2 - 2
imgui_widgets.cpp

@@ -4966,7 +4966,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
         {
         {
             if (flags & ImGuiInputTextFlags_EscapeClearsAll)
             if (flags & ImGuiInputTextFlags_EscapeClearsAll)
             {
             {
-                if (buf[0] != 0)
+                if (state->TextA.Data[0] != 0)
                 {
                 {
                     revert_edit = true;
                     revert_edit = true;
                 }
                 }
@@ -5058,7 +5058,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
             if (flags & ImGuiInputTextFlags_EscapeClearsAll)
             if (flags & ImGuiInputTextFlags_EscapeClearsAll)
             {
             {
                 // Clear input
                 // Clear input
-                IM_ASSERT(buf[0] != 0); // FIXME: use TextA here?
+                IM_ASSERT(state->TextA.Data[0] != 0);
                 apply_new_text = "";
                 apply_new_text = "";
                 apply_new_text_length = 0;
                 apply_new_text_length = 0;
                 value_changed = true;
                 value_changed = true;