diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 863f36a69..1545cf8d8 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -50,6 +50,10 @@ Breaking changes: - Renamed 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap' - IsItemHovered: Changed behavior to return false when querying an item using AllowOverlap mode which is being overlapped. Added ImGuiHoveredFlags_AllowWhenOverlappedByItem. (#6512, #3909, #517) + - Selectable, TreeNode: When using ImGuiSelectableFlags_AllowOverlap/ImGuiTreeNodeFlags_AllowOverlap + and holding item held, overlapping widgets won't appear as hovered. (#6512, #3909) + - Most item types should now work with SetNextItemAllowOverlap(). (#6512, #3909, #517) + - Fixed first frame of an overlap highlighting underlying item if previous frame didn't hover anything. - Kept redirecting enums (will obsolete). Other changes: @@ -77,10 +81,6 @@ Other changes: - IsItemHovered: Added _AllowWhenOverlappedByWindow to ignore window-overlap only. Option ImGuiHoveredFlags_AllowWhenOverlapped now expand into a combination of both _AllowWhenOverlappedByWindow + _AllowWhenOverlappedByItem, matching old behavior. -- Overlapping items: (#6512, #3909, #517) - - Selectable, TreeNode: When using ImGuiSelectableFlags_AllowOverlap/ImGuiTreeNodeFlags_AllowOverlap - and holding item held, overlapping widgets won't appear as hovered. (#6512, #3909) - - Fixed first frame of an overlap highlighting underlying item if previous frame didn't hover anything. - IsWindowHovered: Added support for ImGuiHoveredFlags_Stationary. - IsWindowHovered, IsItemHovered: Assert when passed any unsupported flags. - Tables: Fixed a regression in 1.89.6 leading to the first column of tables with either diff --git a/imgui.cpp b/imgui.cpp index cb61b31e7..63e4f7dd7 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4069,6 +4069,15 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flag return false; SetHoveredID(id); + + // 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. Generally perceived as a front-to-back hit-test. + if (item_flags & ImGuiItemflags_AllowOverlap) + { + g.HoveredIdAllowOverlap = true; + if (g.HoveredIdPreviousFrame != id) + return false; + } } // When disabled we'll return false but still set HoveredId diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 2476a160f..ecdb2d613 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -531,15 +531,6 @@ bool ImGui::ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool if (flatten_hovered_children) 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 (item_flags & ImGuiItemflags_AllowOverlap) - { - if (hovered && g.HoveredIdPreviousFrame != id) - hovered = false; - if (g.HoveredId == id) // FIXME: Added this to match legacy SetItemAllowOverlap(). Investigate precise side-effects of using (hovered==true) instead? - g.HoveredIdAllowOverlap = true; - } - // Mouse handling const ImGuiID test_owner_id = (flags & ImGuiButtonFlags_NoTestKeyOwner) ? ImGuiKeyOwner_Any : id; if (hovered)