From 1546153ca25704bebf4dab13d399f60f6707f430 Mon Sep 17 00:00:00 2001 From: omar Date: Tue, 13 Nov 2018 19:31:10 +0100 Subject: [PATCH] Docking: Fixed a regression where clicking a Tab wouldn't immediately set NavWindow. Which led to breaking the NavSaveLastChildNavWindow/NavRestoreLastChildNavWindow logic. (#2109) --- imgui.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index fb8500af..4c30095d 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -11018,10 +11018,6 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w } } - // When clicked on a tab we requested focus to the docked child - if (tab_bar->WantFocusTabId) - focus_tab_id = tab_bar->WantFocusTabId; - // When clicking on the title bar outside of tabs, we still focus the selected tab for that node if (g.HoveredWindow == host_window && g.HoveredId == 0 && IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max)) { @@ -11037,6 +11033,11 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w if (is_focused && g.NavWindow == host_window && !g.NavWindowingTarget) focus_tab_id = tab_bar->SelectedTabId; + // When clicked on a tab we requested focus to the docked child + // This overrides the value set by "forward focus from host node to selected window". + if (tab_bar->WantFocusTabId) + focus_tab_id = tab_bar->WantFocusTabId; + // Apply navigation focus if (focus_tab_id != 0) if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, focus_tab_id))