From 1566c96ccd5faa7fddf34329687ac16796bebabc Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 8 Jan 2026 17:04:52 +0100 Subject: [PATCH] InputText, Nav: fixed remote/shortcut InputText() not teleporting mouse cursor when nav cursor is active and io.ConfigNavMoveSetMousePos is enabled. Motivated by this, also made SetFocusID() immediately set g.NavIdIsAlive, which is more correct and might be other (positive) subtle side effects. --- docs/CHANGELOG.txt | 3 +++ imgui.cpp | 2 ++ imgui_widgets.cpp | 2 ++ 3 files changed, 7 insertions(+) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 521ec6b53..3a2bea6e2 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -150,6 +150,9 @@ Other Changes: end of a line rather than at the beginning of next line. (#8990, #3237) - Fixed low-level word-wrapping function reading from *text_end when passed a string range. (#9107) [@achabense] +- Nav: + - Fixed remote/shortcut InputText() not teleporting mouse cursor when + nav cursor is visible and `io.ConfigNavMoveSetMousePos` is enabled. - Scrollbar: fixed a codepath leading to a divide-by-zero (which would not be noticeable by user but detected by sanitizers). (#9089) [@judicaelclair] - Added GetItemFlags() in public API for consistency and to expose generic diff --git a/imgui.cpp b/imgui.cpp index 996d162b3..4e59a1a6c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -13055,6 +13055,8 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window) window->NavLastIds[nav_layer] = id; if (g.LastItemData.ID == id) window->NavRectRel[nav_layer] = WindowRectAbsToRel(window, g.LastItemData.NavRect); + if (g.NavId == g.ActiveId && g.ActiveIdIsAlive) + g.NavIdIsAlive = true; if (g.ActiveIdSource == ImGuiInputSource_Keyboard || g.ActiveIdSource == ImGuiInputSource_Gamepad) g.NavHighlightItemUnderNav = true; diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 83e931a0e..88d3b7ca4 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4848,6 +4848,8 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_ SetActiveID(id, window); SetFocusID(id, window); FocusWindow(window); + if (input_requested_by_nav) + SetNavCursorVisibleAfterMove(); } if (g.ActiveId == id) {