mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-04 07:01:04 +01:00 
			
		
		
		
	OpenPopup(): Added ImGuiPopupFlags_NoReopen. Nav, Menus: Fixed click on a BeginMenu() followed by right-arrow. (#1497, #1533)
reopen
This commit is contained in:
		
							
								
								
									
										16
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -10773,16 +10773,22 @@ void ImGui::OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags)
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
        // Gently handle the user mistakenly calling OpenPopup() every frame. It is a programming mistake! However, if we were to run the regular code path, the ui
 | 
			
		||||
        // would become completely unusable because the popup will always be in hidden-while-calculating-size state _while_ claiming focus. Which would be a very confusing
 | 
			
		||||
        // situation for the programmer. Instead, we silently allow the popup to proceed, it will keep reappearing and the programming error will be more obvious to understand.
 | 
			
		||||
        if (g.OpenPopupStack[current_stack_size].PopupId == id && g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1)
 | 
			
		||||
        // Gently handle the user mistakenly calling OpenPopup() every frames: it is likely a programming mistake!
 | 
			
		||||
        // However, if we were to run the regular code path, the ui would become completely unusable because the popup will always be
 | 
			
		||||
        // in hidden-while-calculating-size state _while_ claiming focus. Which is extremely confusing situation for the programmer.
 | 
			
		||||
        // Instead, for successive frames calls to OpenPopup(), we silently avoid reopening even if ImGuiPopupFlags_NoReopen is not specified.
 | 
			
		||||
        bool keep_existing = false;
 | 
			
		||||
        if (g.OpenPopupStack[current_stack_size].PopupId == id)
 | 
			
		||||
            if ((g.OpenPopupStack[current_stack_size].OpenFrameCount == g.FrameCount - 1) || (popup_flags & ImGuiPopupFlags_NoReopen))
 | 
			
		||||
                keep_existing = true;
 | 
			
		||||
        if (keep_existing)
 | 
			
		||||
        {
 | 
			
		||||
            // No reopen
 | 
			
		||||
            g.OpenPopupStack[current_stack_size].OpenFrameCount = popup_ref.OpenFrameCount;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            // Close child popups if any, then flag popup for open/reopen
 | 
			
		||||
            // Reopen: close child popups if any, then flag popup for open/reopen (set position, focus, init navigation)
 | 
			
		||||
            ClosePopupToLevel(current_stack_size, false);
 | 
			
		||||
            g.OpenPopupStack.push_back(popup_ref);
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user