|
@@ -4063,6 +4063,7 @@ ImGuiContext::ImGuiContext(ImFontAtlas* shared_font_atlas)
|
|
|
ActiveIdClickOffset = ImVec2(-1, -1);
|
|
|
ActiveIdWindow = NULL;
|
|
|
ActiveIdSource = ImGuiInputSource_None;
|
|
|
+ ActiveIdDisabledId = 0;
|
|
|
ActiveIdMouseButton = -1;
|
|
|
ActiveIdPreviousFrame = 0;
|
|
|
memset(&DeactivatedItemData, 0, sizeof(DeactivatedItemData));
|
|
@@ -4555,6 +4556,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
|
|
g.ActiveIdWindow = window;
|
|
|
g.ActiveIdHasBeenEditedThisFrame = false;
|
|
|
g.ActiveIdFromShortcut = false;
|
|
|
+ g.ActiveIdDisabledId = 0;
|
|
|
if (id)
|
|
|
{
|
|
|
g.ActiveIdIsAlive = id;
|
|
@@ -4656,6 +4658,7 @@ static ImGuiHoveredFlags ApplyHoverFlagsForTooltip(ImGuiHoveredFlags user_flags,
|
|
|
}
|
|
|
|
|
|
// 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(ImGuiHoveredFlags flags)
|
|
|
{
|
|
@@ -4697,7 +4700,17 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
|
|
|
const ImGuiID id = g.LastItemData.ID;
|
|
|
if ((flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem) == 0)
|
|
|
if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap)
|
|
|
- return false;
|
|
|
+ {
|
|
|
+ // When ActiveId == MoveId it means that either:
|
|
|
+ // - (1) user clicked on void _or_ an item with no id, which triggers moving window (ActiveId is set even when window has _NoMove flag)
|
|
|
+ // - the (id == 0) test handles it, however, IsItemHovered() will leak between id==0 items (mostly visible when using _NoMove). // FIXME: May be fixed.
|
|
|
+ // - (2) user clicked a disabled item. UpdateMouseMovingWindowEndFrame() uses ActiveId == MoveId to avoid interference with item logic + sets ActiveIdDisabledId.
|
|
|
+ bool cancel_is_hovered = true;
|
|
|
+ if (g.ActiveId == window->MoveId && (id == 0 || g.ActiveIdDisabledId == id))
|
|
|
+ cancel_is_hovered = false;
|
|
|
+ if (cancel_is_hovered)
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
// Test if interactions on this window are blocked by an active popup or modal.
|
|
|
// The ImGuiHoveredFlags_AllowWhenBlockedByPopup flag will be tested here.
|
|
@@ -4778,7 +4791,7 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id, ImGuiItemFlags item_flag
|
|
|
if (!g.ActiveIdFromShortcut)
|
|
|
return false;
|
|
|
|
|
|
- // Done with rectangle culling so we can perform heavier checks now.
|
|
|
+ // We are done with rectangle culling so we can perform heavier checks now.
|
|
|
if (!(item_flags & ImGuiItemFlags_NoWindowHoverableCheck) && !IsWindowContentHoverable(window, ImGuiHoveredFlags_None))
|
|
|
{
|
|
|
g.HoveredIdIsDisabled = true;
|
|
@@ -5171,9 +5184,12 @@ void ImGui::UpdateMouseMovingWindowEndFrame()
|
|
|
g.MovingWindow = NULL;
|
|
|
|
|
|
// Cancel moving if clicked over an item which was disabled or inhibited by popups
|
|
|
- // (when g.HoveredIdIsDisabled == true && g.HoveredId == 0 we are inhibited by popups, when g.HoveredIdIsDisabled == true && g.HoveredId != 0 we are over a disabled item)0 already)
|
|
|
+ // (when g.HoveredIdIsDisabled == true && g.HoveredId == 0 we are inhibited by popups, when g.HoveredIdIsDisabled == true && g.HoveredId != 0 we are over a disabled item)
|
|
|
if (g.HoveredIdIsDisabled)
|
|
|
+ {
|
|
|
g.MovingWindow = NULL;
|
|
|
+ g.ActiveIdDisabledId = g.HoveredId;
|
|
|
+ }
|
|
|
}
|
|
|
else if (root_window == NULL && g.NavWindow != NULL)
|
|
|
{
|