|
|
|
@ -6796,9 +6796,14 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
|
|
|
|
IM_ASSERT(window == NULL || window->RootWindow != NULL);
|
|
|
|
|
ImGuiWindow* focus_front_window = window ? window->RootWindowDockStop : NULL;
|
|
|
|
|
ImGuiWindow* display_front_window = window ? window->RootWindow : NULL;
|
|
|
|
|
|
|
|
|
|
// Steal focus on active widgets
|
|
|
|
|
if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindowDockStop != focus_front_window)
|
|
|
|
|
ImGuiDockNode* dock_node = window ? window->DockNode : NULL;
|
|
|
|
|
bool active_id_window_is_dock_node_host = (g.ActiveIdWindow && dock_node && dock_node->HostWindow == g.ActiveIdWindow);
|
|
|
|
|
|
|
|
|
|
// Steal active widgets. Some of the cases it triggers includes:
|
|
|
|
|
// - Focus a window while an InputText in another window is active, if focus happens before the old InputText can run.
|
|
|
|
|
// - When using Nav to activate menu items (due to timing of activating on press->new window appears->losing ActiveId)
|
|
|
|
|
// - Using dock host items (tab, collapse button) can trigger this before we redirect the ActiveIdWindow toward the child window.
|
|
|
|
|
if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindowDockStop != focus_front_window && !active_id_window_is_dock_node_host)
|
|
|
|
|
ClearActiveID();
|
|
|
|
|
|
|
|
|
|
// Passing NULL allow to disable keyboard focus
|
|
|
|
@ -6807,8 +6812,8 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
|
|
|
|
window->LastFrameJustFocused = g.FrameCount;
|
|
|
|
|
|
|
|
|
|
// Select in dock node
|
|
|
|
|
if (window->DockNode && window->DockNode->TabBar)
|
|
|
|
|
window->DockNode->TabBar->SelectedTabId = window->DockNode->TabBar->NextSelectedTabId = window->ID;
|
|
|
|
|
if (dock_node && dock_node->TabBar)
|
|
|
|
|
dock_node->TabBar->SelectedTabId = dock_node->TabBar->NextSelectedTabId = window->ID;
|
|
|
|
|
|
|
|
|
|
// Bring to front
|
|
|
|
|
BringWindowToFocusFront(focus_front_window);
|
|
|
|
|