InputText: do not set WantTextInputNextFrame during the frame InputText is deactivated. (#6341)

This commit is contained in:
lukaasm 2023-04-17 19:37:36 +02:00 committed by ocornut
parent e49d31a1c9
commit 0948cfc19e
2 changed files with 6 additions and 2 deletions

View File

@ -44,6 +44,8 @@ Other changes:
- Tables: Fixed a small miscalculation in TableHeader() leading to an empty tooltip - Tables: Fixed a small miscalculation in TableHeader() leading to an empty tooltip
showing when a sorting column has no visible name. (#6342) [@lukaasm] 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] - Backends: Clear bits sets io.BackendFlags on backend Shutdown(). (#6334, #6335] [@GereonV]
Potentially this would facilitate switching runtime backend mid-session. Potentially this would facilitate switching runtime backend mid-session.

View File

@ -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. // 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. // Down the line we should have a cleaner library-wide concept of Selected vs Active.
g.ActiveIdAllowOverlap = !io.MouseDown[0]; g.ActiveIdAllowOverlap = !io.MouseDown[0];
g.WantTextInputNextFrame = 1;
// Edit in progress // Edit in progress
const float mouse_x = (io.MousePos.x - frame_bb.Min.x - style.FramePadding.x) + state->ScrollX; 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) // 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(); ClearActiveID();
else if (g.ActiveId == id)
g.WantTextInputNextFrame = 1;
// Render frame // Render frame
if (!is_multiline) if (!is_multiline)