From 8cfd963fda9be037afdb1e0d5834d99344713f87 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 14 Jul 2015 09:21:41 -0600 Subject: [PATCH] Popups: removed an apparently unnecessary test in CloseInactivePopups() that broke Combo boxes inside menus (#272) --- imgui.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 64f2716b..c738b2d9 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3172,7 +3172,7 @@ static void CloseInactivePopups() if (g.OpenedPopupStack.empty()) return; - // When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it + // When popups are stacked, clicking on a lower level popups puts focus back to it and close popups above it. // Don't close our own child popup windows int n = 0; if (g.FocusedWindow) @@ -3184,21 +3184,17 @@ static void CloseInactivePopups() continue; IM_ASSERT((popup.Window->Flags & ImGuiWindowFlags_Popup) != 0); if (popup.Window->Flags & ImGuiWindowFlags_ChildWindow) - { - if (g.FocusedWindow->RootWindow != popup.Window->RootWindow) - break; - } - else - { - bool has_focus = false; - for (int m = n; m < g.OpenedPopupStack.Size && !has_focus; m++) - has_focus = (g.OpenedPopupStack[m].Window && g.OpenedPopupStack[m].Window->RootWindow == g.FocusedWindow->RootWindow); - if (!has_focus) - break; - } + continue; + + bool has_focus = false; + for (int m = n; m < g.OpenedPopupStack.Size && !has_focus; m++) + has_focus = (g.OpenedPopupStack[m].Window && g.OpenedPopupStack[m].Window->RootWindow == g.FocusedWindow->RootWindow); + if (!has_focus) + break; } } - g.OpenedPopupStack.resize(n); + if (n < g.OpenedPopupStack.Size) // This test is not required but it allows to set a useful breakpoint on the line below + g.OpenedPopupStack.resize(n); } static ImGuiWindow* GetFrontMostModalRootWindow()