mirror of
https://github.com/Drezil/imgui.git
synced 2025-01-11 16:26:35 +00: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:
parent
6da8a77fa3
commit
0cdd050cd7
11
imgui.cpp
11
imgui.cpp
@ -7536,16 +7536,23 @@ 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);
|
want_open = (!opened && hovered);
|
||||||
else if (pressed && menuset_opened)
|
else if (opened && pressed && menuset_opened)
|
||||||
{
|
{
|
||||||
ClosePopup(label); // click again to toggle
|
ClosePopup(label); // click again to toggle
|
||||||
want_open = opened = false;
|
want_open = opened = false;
|
||||||
}
|
}
|
||||||
else if (pressed)
|
else if (pressed)
|
||||||
want_open = true;
|
want_open = true;
|
||||||
else if (hovered && menuset_opened)
|
else if (hovered && menuset_opened && !opened)
|
||||||
want_open = true;
|
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;
|
opened |= want_open;
|
||||||
if (want_open)
|
if (want_open)
|
||||||
ImGui::OpenPopup(label);
|
ImGui::OpenPopup(label);
|
||||||
|
Loading…
Reference in New Issue
Block a user