|
@@ -3278,42 +3278,46 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|
|
{
|
|
|
if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
|
|
|
return false;
|
|
|
- return IsItemFocused();
|
|
|
+ if (!IsItemFocused())
|
|
|
+ return false;
|
|
|
}
|
|
|
-
|
|
|
- // Test for bounding box overlap, as updated as ItemAdd()
|
|
|
- ImGuiItemStatusFlags status_flags = g.LastItemData.StatusFlags;
|
|
|
- if (!(status_flags & ImGuiItemStatusFlags_HoveredRect))
|
|
|
- return false;
|
|
|
- IM_ASSERT((flags & (ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy)) == 0); // Flags not supported by this function
|
|
|
-
|
|
|
- // Test if we are hovering the right window (our window could be behind another window)
|
|
|
- // [2021/03/02] Reworked / reverted the revert, finally. Note we want e.g. BeginGroup/ItemAdd/EndGroup to work as well. (#3851)
|
|
|
- // [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
|
|
|
- // 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
|
|
|
- // the test that has been running for a long while.
|
|
|
- if (g.HoveredWindow != window && (status_flags & ImGuiItemStatusFlags_HoveredWindow) == 0)
|
|
|
- if ((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0)
|
|
|
+ else
|
|
|
+ {
|
|
|
+ // Test for bounding box overlap, as updated as ItemAdd()
|
|
|
+ ImGuiItemStatusFlags status_flags = g.LastItemData.StatusFlags;
|
|
|
+ if (!(status_flags & ImGuiItemStatusFlags_HoveredRect))
|
|
|
return false;
|
|
|
+ IM_ASSERT((flags & (ImGuiHoveredFlags_AnyWindow | ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows | ImGuiHoveredFlags_NoPopupHierarchy)) == 0); // Flags not supported by this function
|
|
|
+
|
|
|
+ // Test if we are hovering the right window (our window could be behind another window)
|
|
|
+ // [2021/03/02] Reworked / reverted the revert, finally. Note we want e.g. BeginGroup/ItemAdd/EndGroup to work as well. (#3851)
|
|
|
+ // [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
|
|
|
+ // 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
|
|
|
+ // the test that has been running for a long while.
|
|
|
+ if (g.HoveredWindow != window && (status_flags & ImGuiItemStatusFlags_HoveredWindow) == 0)
|
|
|
+ if ((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ // Test if another item is active (e.g. being dragged)
|
|
|
+ if ((flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) == 0)
|
|
|
+ if (g.ActiveId != 0 && g.ActiveId != g.LastItemData.ID && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId)
|
|
|
+ return false;
|
|
|
|
|
|
- // Test if another item is active (e.g. being dragged)
|
|
|
- if ((flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) == 0)
|
|
|
- if (g.ActiveId != 0 && g.ActiveId != g.LastItemData.ID && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId)
|
|
|
+ // Test if interactions on this window are blocked by an active popup or modal.
|
|
|
+ // The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
|
|
|
+ if (!IsWindowContentHoverable(window, flags))
|
|
|
return false;
|
|
|
|
|
|
- // Test if interactions on this window are blocked by an active popup or modal.
|
|
|
- // The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
|
|
|
- if (!IsWindowContentHoverable(window, flags))
|
|
|
- return false;
|
|
|
+ // Test if the item is disabled
|
|
|
+ if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
|
|
|
+ return false;
|
|
|
|
|
|
- // Test if the item is disabled
|
|
|
- if ((g.LastItemData.InFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled))
|
|
|
- return false;
|
|
|
+ // Special handling for calling after Begin() which represent the title bar or tab.
|
|
|
+ // When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case.
|
|
|
+ if (g.LastItemData.ID == window->MoveId && window->WriteAccessed)
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- // Special handling for calling after Begin() which represent the title bar or tab.
|
|
|
- // When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case.
|
|
|
- if (g.LastItemData.ID == window->MoveId && window->WriteAccessed)
|
|
|
- return false;
|
|
|
return true;
|
|
|
}
|
|
|
|