mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 13:37:00 +00:00
Clicking on a widget in a child window focus the parent window (#147)
However SetWindowFocus() called on a child window prior to calling Begin() on said child won;'t work yet.
This commit is contained in:
parent
b911f96a56
commit
9b6fa29022
@ -2774,7 +2774,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size, float bg
|
|||||||
window->IDStack.resize(0);
|
window->IDStack.resize(0);
|
||||||
ImGui::PushID(window);
|
ImGui::PushID(window);
|
||||||
|
|
||||||
// Move window (at the beginning of the frame to avoid input lag or sheering)
|
// Move window (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows.
|
||||||
const ImGuiID move_id = window->GetID("#MOVE");
|
const ImGuiID move_id = window->GetID("#MOVE");
|
||||||
RegisterAliveId(move_id);
|
RegisterAliveId(move_id);
|
||||||
if (g.ActiveId == move_id)
|
if (g.ActiveId == move_id)
|
||||||
@ -3127,6 +3127,12 @@ void ImGui::End()
|
|||||||
static void FocusWindow(ImGuiWindow* window)
|
static void FocusWindow(ImGuiWindow* window)
|
||||||
{
|
{
|
||||||
ImGuiState& g = *GImGui;
|
ImGuiState& g = *GImGui;
|
||||||
|
|
||||||
|
// Always focus the root window
|
||||||
|
// FIXME: RootWindow is set as we do Begin() on the window, so this won't work if called SetWindowFocus(const char* name) on a child window prior to window calling Begin(). Bit of an edge.
|
||||||
|
if (window->RootWindow)
|
||||||
|
window = window->RootWindow;
|
||||||
|
|
||||||
g.FocusedWindow = window;
|
g.FocusedWindow = window;
|
||||||
|
|
||||||
if (g.Windows.back() == window)
|
if (g.Windows.back() == window)
|
||||||
|
Loading…
Reference in New Issue
Block a user