mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 21:09:01 +08:00
parent
009276b6cb
commit
8241cd6284
11
imgui.cpp
11
imgui.cpp
@ -2927,6 +2927,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
||||
}
|
||||
g.ActiveId = id;
|
||||
g.ActiveIdAllowOverlap = false;
|
||||
g.ActiveIdNoClearOnFocusLoss = false;
|
||||
g.ActiveIdWindow = window;
|
||||
g.ActiveIdHasBeenEditedThisFrame = false;
|
||||
if (id)
|
||||
@ -2944,7 +2945,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
||||
|
||||
void ImGui::ClearActiveID()
|
||||
{
|
||||
SetActiveID(0, NULL);
|
||||
SetActiveID(0, NULL); // g.ActiveId = 0;
|
||||
}
|
||||
|
||||
void ImGui::SetHoveredID(ImGuiID id)
|
||||
@ -3301,6 +3302,7 @@ void ImGui::StartMouseMovingWindow(ImGuiWindow* window)
|
||||
FocusWindow(window);
|
||||
SetActiveID(window->MoveId, window);
|
||||
g.NavDisableHighlight = true;
|
||||
g.ActiveIdNoClearOnFocusLoss = true;
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - window->RootWindow->Pos;
|
||||
|
||||
bool can_move_window = true;
|
||||
@ -6147,9 +6149,12 @@ void ImGui::FocusWindow(ImGuiWindow* window)
|
||||
ImGuiWindow* focus_front_window = window ? window->RootWindow : NULL; // NB: In docking branch this is window->RootWindowDockStop
|
||||
ImGuiWindow* display_front_window = window ? window->RootWindow : NULL;
|
||||
|
||||
// Steal focus on active widgets
|
||||
// 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)
|
||||
if (g.ActiveId != 0 && g.ActiveIdWindow && g.ActiveIdWindow->RootWindow != focus_front_window)
|
||||
ClearActiveID();
|
||||
if (!g.ActiveIdNoClearOnFocusLoss)
|
||||
ClearActiveID();
|
||||
|
||||
// Passing NULL allow to disable keyboard focus
|
||||
if (!window)
|
||||
|
@ -1147,6 +1147,7 @@ struct ImGuiContext
|
||||
float ActiveIdTimer;
|
||||
bool ActiveIdIsJustActivated; // Set at the time of activation for one frame
|
||||
bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always)
|
||||
bool ActiveIdNoClearOnFocusLoss; // Disable losing active id if the active id window gets unfocused.
|
||||
bool ActiveIdHasBeenPressedBefore; // Track whether the active id led to a press (this is to allow changing between PressOnClick and PressOnRelease without pressing twice). Used by range_select branch.
|
||||
bool ActiveIdHasBeenEditedBefore; // Was the value associated to the widget Edited over the course of the Active state.
|
||||
bool ActiveIdHasBeenEditedThisFrame;
|
||||
|
Loading…
Reference in New Issue
Block a user