mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-23 12:27:01 +00:00
WIP Menus: Fixed closing popup on menu item activation when a child menu is open from the popup (#126)
This commit is contained in:
parent
3498617a3c
commit
48ede93a58
11
imgui.cpp
11
imgui.cpp
@ -3056,14 +3056,15 @@ static void ClosePopup(const char* str_id) // not exposed because 'id' scope is
|
|||||||
void ImGui::CloseCurrentPopup()
|
void ImGui::CloseCurrentPopup()
|
||||||
{
|
{
|
||||||
ImGuiState& g = *GImGui;
|
ImGuiState& g = *GImGui;
|
||||||
if (g.CurrentPopupStack.empty() || g.OpenedPopupStack.empty() || g.CurrentPopupStack.back().PopupID != g.OpenedPopupStack.back().PopupID)
|
int popup_idx = (int)g.CurrentPopupStack.size() - 1;
|
||||||
|
if (popup_idx < 0 || popup_idx > (int)g.OpenedPopupStack.size() || g.CurrentPopupStack[popup_idx].PopupID != g.OpenedPopupStack[popup_idx].PopupID)
|
||||||
return;
|
return;
|
||||||
if (g.CurrentWindow->PopupID == g.OpenedPopupStack.back().PopupID && g.Windows.size() >= 2)
|
if (g.CurrentWindow->PopupID == g.OpenedPopupStack[popup_idx].PopupID && g.Windows.size() > 1)
|
||||||
FocusWindow(g.Windows[g.Windows.size()-2]);
|
FocusWindow(g.Windows[g.Windows.size()-2]);
|
||||||
g.OpenedPopupStack.pop_back();
|
g.OpenedPopupStack.resize(popup_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CloseAllPopups()
|
static void CloseCurrentMenus()
|
||||||
{
|
{
|
||||||
// Close all popups
|
// Close all popups
|
||||||
// FIXME-MENUS: invalid for popup->menus with current BeginMenu() scheme
|
// FIXME-MENUS: invalid for popup->menus with current BeginMenu() scheme
|
||||||
@ -7317,7 +7318,7 @@ static bool SelectableEx(const char* label, bool selected, const ImVec2& size_ar
|
|||||||
|
|
||||||
// Automatically close popups
|
// Automatically close popups
|
||||||
if (pressed && (window->Flags & ImGuiWindowFlags_ChildMenu))
|
if (pressed && (window->Flags & ImGuiWindowFlags_ChildMenu))
|
||||||
CloseAllPopups();
|
CloseCurrentMenus();
|
||||||
else if (pressed && (window->Flags & ImGuiWindowFlags_Popup))
|
else if (pressed && (window->Flags & ImGuiWindowFlags_Popup))
|
||||||
ImGui::CloseCurrentPopup();
|
ImGui::CloseCurrentPopup();
|
||||||
return pressed;
|
return pressed;
|
||||||
|
Loading…
Reference in New Issue
Block a user