Overlap: moved ImGuiItemflags_AllowOverlap handling from ButtoBehavior() to ItemHoverable() now that it is possible. (#6512, #3909, #517)

This allows DragXXX, SliderXXX, PlotXXX etc to honor SetNextItemAllowOverlap().
This commit is contained in:
ocornut
2023-06-28 13:51:50 +02:00
parent 4dee919bc0
commit 6137443d24
3 changed files with 13 additions and 13 deletions

View File

@ -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