mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 07:36:35 +00:00
parent
3b3af6b731
commit
615e9ae345
13
imgui.cpp
13
imgui.cpp
@ -6796,9 +6796,14 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
|||||||
IM_ASSERT(window == NULL || window->RootWindow != NULL);
|
IM_ASSERT(window == NULL || window->RootWindow != NULL);
|
||||||
ImGuiWindow* focus_front_window = window ? window->RootWindowDockStop : NULL;
|
ImGuiWindow* focus_front_window = window ? window->RootWindowDockStop : NULL;
|
||||||
ImGuiWindow* display_front_window = window ? window->RootWindow : NULL;
|
ImGuiWindow* display_front_window = window ? window->RootWindow : NULL;
|
||||||
|
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 focus on active widgets
|
// Steal active widgets. Some of the cases it triggers includes:
|
||||||
if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindowDockStop != focus_front_window)
|
// - 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();
|
ClearActiveID();
|
||||||
|
|
||||||
// Passing NULL allow to disable keyboard focus
|
// Passing NULL allow to disable keyboard focus
|
||||||
@ -6807,8 +6812,8 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
|||||||
window->LastFrameJustFocused = g.FrameCount;
|
window->LastFrameJustFocused = g.FrameCount;
|
||||||
|
|
||||||
// Select in dock node
|
// Select in dock node
|
||||||
if (window->DockNode && window->DockNode->TabBar)
|
if (dock_node && dock_node->TabBar)
|
||||||
window->DockNode->TabBar->SelectedTabId = window->DockNode->TabBar->NextSelectedTabId = window->ID;
|
dock_node->TabBar->SelectedTabId = dock_node->TabBar->NextSelectedTabId = window->ID;
|
||||||
|
|
||||||
// Bring to front
|
// Bring to front
|
||||||
BringWindowToFocusFront(focus_front_window);
|
BringWindowToFocusFront(focus_front_window);
|
||||||
|
@ -7289,6 +7289,11 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open,
|
|||||||
tab_bar->NextSelectedTabId = id;
|
tab_bar->NextSelectedTabId = id;
|
||||||
hovered |= (g.HoveredId == id);
|
hovered |= (g.HoveredId == id);
|
||||||
|
|
||||||
|
// Transfer active id window so the active id is not owned by the dock host (as StartMouseMovingWindow()
|
||||||
|
// will only do it on the drag). This allows FocusWindow() to be more conservative in how it clears active id.
|
||||||
|
if (held && docked_window && g.ActiveId == id && g.ActiveIdIsJustActivated)
|
||||||
|
g.ActiveIdWindow = docked_window;
|
||||||
|
|
||||||
// Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered)
|
// Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered)
|
||||||
if (!held)
|
if (!held)
|
||||||
SetItemAllowOverlap();
|
SetItemAllowOverlap();
|
||||||
|
Loading…
Reference in New Issue
Block a user