mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
ButtonBehavior: Fixed an edge case where changing widget type/behavior while active and using same id could lead to an assert. (#6304)
+ Demo: use BeginDisabled() block in BackendFlags section. I'd still consider this undefined behavior as some combination may not work properly, but let's fix things while we can as we encounter them.
This commit is contained in:
@ -638,7 +638,12 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool
|
||||
g.ActiveIdClickOffset = g.IO.MousePos - bb.Min;
|
||||
|
||||
const int mouse_button = g.ActiveIdMouseButton;
|
||||
if (IsMouseDown(mouse_button, test_owner_id))
|
||||
if (mouse_button == -1)
|
||||
{
|
||||
// Fallback for the rare situation were g.ActiveId was set programmatically or from another widget (e.g. #6304).
|
||||
ClearActiveID();
|
||||
}
|
||||
else if (IsMouseDown(mouse_button, test_owner_id))
|
||||
{
|
||||
held = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user