MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / IsItemHovered

Method IsItemHovered

Dependencies/ImGui/src/imgui.cpp:4639–4725  ·  view source on GitHub ↗

This is roughly matching the behavior of internal-facing ItemHoverable() - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered() - this should work even for non-interactive items that have no ID, so we cannot use LastItemId

Source from the content-addressed store, hash-verified

4637// - we allow hovering to be true when ActiveId==window->MoveID, so that clicking on non-interactive items such as a Text() item still returns true with IsItemHovered()
4638// - this should work even for non-interactive items that have no ID, so we cannot use LastItemId
4639bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
4640{
4641 ImGuiContext& g = *GImGui;
4642 ImGuiWindow* window = g.CurrentWindow;
4643 IM_ASSERT_USER_ERROR((flags & ~ImGuiHoveredFlags_AllowedMaskForIsItemHovered) == 0, "Invalid flags for IsItemHovered()!");
4644
4645 if (g.NavHighlightItemUnderNav && g.NavCursorVisible && !(flags & ImGuiHoveredFlags_NoNavOverride))
4646 {
4647 if (!IsItemFocused())
4648 return false;
4649 if ((g.LastItemData.ItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
4650 return false;
4651
4652 if (flags & ImGuiHoveredFlags_ForTooltip)
4653 flags = ApplyHoverFlagsForTooltip(flags, g.Style.HoverFlagsForTooltipNav);
4654 }
4655 else
4656 {
4657 // Test for bounding box overlap, as updated as ItemAdd()
4658 ImGuiItemStatusFlags status_flags = g.LastItemData.StatusFlags;
4659 if (!(status_flags & ImGuiItemStatusFlags_HoveredRect))
4660 return false;
4661
4662 if (flags & ImGuiHoveredFlags_ForTooltip)
4663 flags = ApplyHoverFlagsForTooltip(flags, g.Style.HoverFlagsForTooltipMouse);
4664
4665 // Done with rectangle culling so we can perform heavier checks now
4666 // Test if we are hovering the right window (our window could be behind another window)
4667 // [2021/03/02] Reworked / reverted the revert, finally. Note we want e.g. BeginGroup/ItemAdd/EndGroup to work as well. (#3851)
4668 // [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable
4669 // to use IsItemHovered() after EndChild() itself. Until a solution is found I believe reverting to the test from 2017/09/27 is safe since this was
4670 // the test that has been running for a long while.
4671 if (g.HoveredWindow != window && (status_flags & ImGuiItemStatusFlags_HoveredWindow) == 0)
4672 if ((flags & ImGuiHoveredFlags_AllowWhenOverlappedByWindow) == 0)
4673 return false;
4674
4675 // Test if another item is active (e.g. being dragged)
4676 const ImGuiID id = g.LastItemData.ID;
4677 if ((flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) == 0)
4678 if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap)
4679 if (g.ActiveId != window->MoveId && g.ActiveId != window->TabId)
4680 return false;
4681
4682 // Test if interactions on this window are blocked by an active popup or modal.
4683 // The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
4684 if (!IsWindowContentHoverable(window, flags) && !(g.LastItemData.ItemFlags & ImGuiItemFlags_NoWindowHoverableCheck))
4685 return false;
4686
4687 // Test if the item is disabled
4688 if ((g.LastItemData.ItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
4689 return false;
4690
4691 // Special handling for calling after Begin() which represent the title bar or tab.
4692 // When the window is skipped/collapsed (SkipItems==true) that last item (always ->MoveId submitted by Begin)
4693 // will never be overwritten so we need to detect the case.
4694 if (id == window->MoveId && window->WriteAccessed)
4695 return false;
4696

Callers

nothing calls this directly

Calls 3

GetIDFromPosMethod · 0.80

Tested by

no test coverage detected