1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-09-24 19:48:34 +02:00

WIP Menus: fixed recycling menu level during the same frame (#126)

We could also enforce "clearing" the window and recycle immediate which
sort of work, but it would be a less tested code path.
This commit is contained in:
ocornut 2015-05-18 21:26:46 +01:00
parent 6da8a77fa3
commit 0cdd050cd7

View File

@ -7536,16 +7536,23 @@ bool ImGui::BeginMenu(const char* label)
bool want_open = false;
if (window->Flags & (ImGuiWindowFlags_Popup|ImGuiWindowFlags_ChildMenu))
want_open = (!opened && hovered);
else if (pressed && menuset_opened)
else if (opened && pressed && menuset_opened)
{
ClosePopup(label); // click again to toggle
want_open = opened = false;
}
else if (pressed)
want_open = true;
else if (hovered && menuset_opened)
else if (hovered && menuset_opened && !opened)
want_open = true;
if (!opened && want_open && g.OpenedPopupStack.size() > g.CurrentPopupStack.size())
{
// Don't recycle same menu level in the same frame, first close the other menu and yield for a frame.
ImGui::OpenPopup(label);
return false;
}
opened |= want_open;
if (want_open)
ImGui::OpenPopup(label);