mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
WIP Menus: Closing sub-menu when hovering something else in the same parent window (#126)
Immediate open/close is error-prone
This commit is contained in:
parent
83b10f77a9
commit
4eeba016f6
14
imgui.cpp
14
imgui.cpp
@ -7603,15 +7603,17 @@ bool ImGui::BeginMenu(const char* label)
|
|||||||
|
|
||||||
bool want_open = false;
|
bool want_open = false;
|
||||||
if (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
|
if (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
|
||||||
want_open = (!opened && hovered);
|
|
||||||
else if (opened && pressed && menuset_opened)
|
|
||||||
{
|
{
|
||||||
ClosePopup(label); // click again to toggle
|
if (opened && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id)
|
||||||
|
ClosePopup(label);
|
||||||
|
want_open = (!opened && hovered);
|
||||||
|
}
|
||||||
|
else if (opened && pressed && menuset_opened) // menu-bar: click open menu to close
|
||||||
|
{
|
||||||
|
ClosePopup(label);
|
||||||
want_open = opened = false;
|
want_open = opened = false;
|
||||||
}
|
}
|
||||||
else if (pressed)
|
else if (pressed || (hovered && menuset_opened && !opened)) // menu-bar: first click to open, then hover to open others
|
||||||
want_open = true;
|
|
||||||
else if (hovered && menuset_opened && !opened)
|
|
||||||
want_open = true;
|
want_open = true;
|
||||||
|
|
||||||
if (!opened && want_open && g.OpenedPopupStack.size() > g.CurrentPopupStack.size())
|
if (!opened && want_open && g.OpenedPopupStack.size() > g.CurrentPopupStack.size())
|
||||||
|
Loading…
Reference in New Issue
Block a user