From 6ca1556d029c9db8ccca30249f41fa1cca2a3445 Mon Sep 17 00:00:00 2001 From: domgho Date: Sun, 29 Sep 2019 12:29:48 +0200 Subject: [PATCH] Nav: Fixed SetItemDefaultFocus() from not scrolling when item is partially visible. (#2814, #2812) --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index a51c91bb..e4638cc5 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -64,6 +64,8 @@ Other changes: - Nav: Fixed an issue with Gamepad navigation when the movement lead to a scroll and frame time > repeat rate. Triggering a new move request on the same frame as a move result lead to an incorrect calculation and loss of navigation id. (#6171) +- Nav: Fixed SetItemDefaultFocus() from not scrolling when item is partially visible. + (#2814, #2812) [@DomGries] - IO: Lifted constraint to call io.AddEventXXX functions from current context. (#4921, #5856, #6199) - InputText: Fixed not being able to use CTRL+Tab while an InputText() using Tab for completion or textinput is active (regresion from 1.89). diff --git a/imgui.cpp b/imgui.cpp index 8507c560..075adddd 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -7505,7 +7505,7 @@ void ImGui::SetItemDefaultFocus() NavUpdateAnyRequestFlag(); // Scroll could be done in NavInitRequestApplyResult() via an opt-in flag (we however don't want regular init requests to scroll) - if (!IsItemVisible()) + if (!window->ClipRect.Contains(g.LastItemData.Rect)) ScrollToRectEx(window, g.LastItemData.Rect, ImGuiScrollFlags_None); }