mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-11-04 09:44:29 +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:
		
							
								
								
									
										11
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user