Skip to content

Commit

Permalink
Fix IsItemHovered() issue on child by temporarily reverting 344d48b. …
Browse files Browse the repository at this point in the history
…This is not the ideal solution. (Fix ocornut#1370)
  • Loading branch information
ocornut committed Oct 16, 2017
1 parent 633f60c commit c76f014
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1986,16 +1986,21 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id)
return true;
}

// This is roughly matching the behavior of internal-facing ItemHoverable() which is
// 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
bool ImGui::IsItemHovered()
{
ImGuiContext& g = *GImGui;

ImGuiWindow* window = g.CurrentWindow;
if (!window->DC.LastItemRectHoveredRect)
return false;
if (g.HoveredWindow != window)
// [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)
// return false;
if (g.HoveredRootWindow != window->RootWindow)
return false;
if (g.ActiveId != 0 && g.ActiveId != window->DC.LastItemId && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId)
return false;
Expand Down

0 comments on commit c76f014

Please sign in to comment.