diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 85f05c8a2..911be774d 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -44,6 +44,8 @@ Other changes: - Tables: Fixed a small miscalculation in TableHeader() leading to an empty tooltip showing when a sorting column has no visible name. (#6342) [@lukaasm] +- InputText: Avoid setting io.WantTextInputNextFrame during the deactivation frame. + (#6341) [@lukaasm] - Backends: Clear bits sets io.BackendFlags on backend Shutdown(). (#6334, #6335] [@GereonV] Potentially this would facilitate switching runtime backend mid-session. diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 3f07ff752..ed38787de 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4296,7 +4296,6 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ // Although we are active we don't prevent mouse from hovering other elements unless we are interacting right now with the widget. // Down the line we should have a cleaner library-wide concept of Selected vs Active. g.ActiveIdAllowOverlap = !io.MouseDown[0]; - g.WantTextInputNextFrame = 1; // Edit in progress const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + state->ScrollX; @@ -4735,8 +4734,11 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ } // Release active ID at the end of the function (so e.g. pressing Return still does a final application of the value) - if (clear_active_id && g.ActiveId == id) + // Otherwise request text input ahead for next frame. + if (g.ActiveId == id && clear_active_id) ClearActiveID(); + else if (g.ActiveId == id) + g.WantTextInputNextFrame = 1; // Render frame if (!is_multiline)