mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-11-04 01:34:32 +00:00 
			
		
		
		
	ButtonBehavior: Fixed ImGuiButtonFlags_AllowOverlapMode to avoid temporarily activating widgets on click before they have been correctly double-hovered. (#319, #600)
This commit is contained in:
		@@ -5821,6 +5821,10 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
 | 
				
			|||||||
    if ((flags & ImGuiButtonFlags_FlattenChilds) && g.HoveredRootWindow == window)
 | 
					    if ((flags & ImGuiButtonFlags_FlattenChilds) && g.HoveredRootWindow == window)
 | 
				
			||||||
        g.HoveredWindow = backup_hovered_window;
 | 
					        g.HoveredWindow = backup_hovered_window;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one.
 | 
				
			||||||
 | 
					    if (hovered && (flags & ImGuiButtonFlags_AllowOverlapMode) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0))
 | 
				
			||||||
 | 
					        hovered = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (hovered)
 | 
					    if (hovered)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
 | 
					        if (!(flags & ImGuiButtonFlags_NoKeyModifiers) || (!g.IO.KeyCtrl && !g.IO.KeyShift && !g.IO.KeyAlt))
 | 
				
			||||||
@@ -5880,10 +5884,6 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // AllowOverlap mode (rarely used) requires previous frame HoveredId to be null or to match. This allows using patterns where a later submitted widget overlaps a previous one.
 | 
					 | 
				
			||||||
    if (hovered && (flags & ImGuiButtonFlags_AllowOverlapMode) && (g.HoveredIdPreviousFrame != id && g.HoveredIdPreviousFrame != 0))
 | 
					 | 
				
			||||||
        hovered = pressed = held = false;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (out_hovered) *out_hovered = hovered;
 | 
					    if (out_hovered) *out_hovered = hovered;
 | 
				
			||||||
    if (out_held) *out_held = held;
 | 
					    if (out_held) *out_held = held;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user