diff --git a/imgui.cpp b/imgui.cpp index daf39ec7..e9795c8d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -2027,6 +2027,8 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window) // Assume that SetFocusID() is called in the context where its NavLayer is the current layer, which is the case everywhere we call it. const int nav_layer = window->DC.NavLayerCurrent; + if (g.NavWindow != window) + g.NavInitRequest = false; g.NavId = id; g.NavWindow = window; g.NavLayer = nav_layer; @@ -6238,8 +6240,7 @@ void ImGui::FocusWindow(ImGuiWindow* window) g.NavMousePosDirty = true; if (window && window->NavLastChildNavWindow != NULL) window->NavLastChildNavWindow = NULL; - if (g.NavInitRequest) - g.NavInitRequest = false; + g.NavInitRequest = false; } // Passing NULL allow to disable keyboard focus diff --git a/imgui_internal.h b/imgui_internal.h index a44eba4f..0c93de71 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -621,7 +621,7 @@ struct ImGuiContext int NavLayer; // Layer we are navigating on. For now the system is hard-coded for 0=main contents and 1=menu/title bar, may expose layers later. int NavIdTabCounter; // == NavWindow->DC.FocusIdxTabCounter at time of NavId processing bool NavIdIsAlive; // Nav widget has been seen this frame ~~ NavRefRectRel is valid - bool NavMousePosDirty; + bool NavMousePosDirty; // When set we will update mouse position if (NavFlags & ImGuiNavFlags_MoveMouse) if set bool NavDisableHighlight; // When user starts using mouse, we hide gamepad/keyboard highlight (nb: but they are still available, which is why NavDisableHighlight isn't always != NavDisableMouseHover) bool NavDisableMouseHover; // When user starts using gamepad/keyboard, we hide mouse hovering highlight until mouse is touched again. bool NavAnyRequest; // ~~ NavMoveRequest || NavInitRequest