Quellcode durchsuchen

InputText: reactivating last activated InputText() doesn't restore horizontal scrolling.

Honestly not sure if the opposite is preferable or not (added commented out in the inactivate render path to test that).
Current behavior added along with recycling: f9928e96c7c762f97bbdf8cf48e04097b56da84a
ocornut vor 8 Monaten
Ursprung
Commit
d2645423de
2 geänderte Dateien mit 5 neuen und 2 gelöschten Zeilen
  1. 2 0
      docs/CHANGELOG.txt
  2. 3 2
      imgui_widgets.cpp

+ 2 - 0
docs/CHANGELOG.txt

@@ -58,6 +58,8 @@ Other changes:
   processing errors outside of the NewFrame()..EndFrame() scope. (#1651)
   processing errors outside of the NewFrame()..EndFrame() scope. (#1651)
 - Tables: fixed SetNextWindowScroll() value being ignored by BeginTable() during
 - Tables: fixed SetNextWindowScroll() value being ignored by BeginTable() during
   the first frame or when scrolling flags have changed. (#8196)
   the first frame or when scrolling flags have changed. (#8196)
+- InputText: reactivating last activated InputText() doesn't restore horizontal scrolling
+  (which was disabled during deactivation anyway).
 - Misc: changed embedded ProggyClean encoding to save a bit of binary space (~12kb to 9.5kb).
 - Misc: changed embedded ProggyClean encoding to save a bit of binary space (~12kb to 9.5kb).
 - Misc: added IMGUI_DISABLE_DEFAULT_FONT to strip embedded font from binary. (#8161)
 - Misc: added IMGUI_DISABLE_DEFAULT_FONT to strip embedded font from binary. (#8161)
   [@demonese]
   [@demonese]

+ 3 - 2
imgui_widgets.cpp

@@ -4537,6 +4537,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
         state->TextA.resize(buf_size + 1);          // we use +1 to make sure that .Data is always pointing to at least an empty string.
         state->TextA.resize(buf_size + 1);          // we use +1 to make sure that .Data is always pointing to at least an empty string.
         state->TextLen = (int)strlen(buf);
         state->TextLen = (int)strlen(buf);
         memcpy(state->TextA.Data, buf, state->TextLen + 1);
         memcpy(state->TextA.Data, buf, state->TextLen + 1);
+        state->Scroll = ImVec2(0.0f, 0.0f);
 
 
         if (recycle_state)
         if (recycle_state)
         {
         {
@@ -4546,7 +4547,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
         }
         }
         else
         else
         {
         {
-            state->Scroll = ImVec2(0.0f, 0.0f);
             stb_textedit_initialize_state(state->Stb, !is_multiline);
             stb_textedit_initialize_state(state->Stb, !is_multiline);
         }
         }
 
 
@@ -5287,8 +5287,9 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
 
 
         if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length)
         if (is_multiline || (buf_display_end - buf_display) < buf_display_max_length)
         {
         {
+            const ImVec2 draw_scroll = /*state ? ImVec2(state->Scroll.x, 0.0f) :*/ ImVec2(0.0f, 0.0f); // Preserve scroll when inactive?
             ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text);
             ImU32 col = GetColorU32(is_displaying_hint ? ImGuiCol_TextDisabled : ImGuiCol_Text);
-            draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect);
+            draw_window->DrawList->AddText(g.Font, g.FontSize, draw_pos - draw_scroll, col, buf_display, buf_display_end, 0.0f, is_multiline ? NULL : &clip_rect);
         }
         }
     }
     }