// Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
// Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
// If a menu with same the ID was already submitted, we will append to it, matching the behavior of Begin().
// We are relying on a O(N) search - so O(N log N) over the frame - which seems like the most efficient for the expected small amount of BeginMenu() calls per frame.
// If somehow this is ever becoming a problem we can switch to use e.g. a ImGuiStorager mapping key to last frame used.
if(g.MenusIdSubmittedThisFrame.contains(id))
{
{
// Menu with same ID was already created - append to it.
if(menu_is_open)
if(menu_is_open)
menu_is_open=BeginPopupEx(id,flags);// menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
menu_is_open=BeginPopupEx(id,flags);// menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
if (!menu_is_open)
else
g.NextWindowData.ClearFlags();// We behave like Begin() and need to consume those values
g.NextWindowData.ClearFlags();// we behave like Begin() and need to consume those values
returnmenu_is_open;
returnmenu_is_open;
}
}
else
{
// Tag menu as used. Next time BeginMenu() with same ID is called it will append to existing menu
g.RenderedMenusId.push_back(id);// Tag menu as used. Next time BeginMenu() with same ID is called it will append to existing menu.