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:
ocornut 2015-05-26 15:01:04 +01:00
parent 83b10f77a9
commit 4eeba016f6

View File

@ -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())