Test hover against the hit rect, not the bare frame rect

CreateBackdrop widens a frame's hit rect by the border, so mouse focus
and OnEnter/OnLeave cover a band that plain MouseIsOver reports as
outside. Add MouseIsOverHitRect, which passes the frame's hit rect
insets as MouseIsOver offsets, and use it at the unpadded call sites.
The XP bar's hover text follows the same OnEnter/OnLeave flag as its
fade.
This commit is contained in:
Brues
2026-10-22 21:36:27 -05:00
parent 9cb21b982b
commit b9f473c049
6 changed files with 24 additions and 11 deletions
+12
View File
@@ -1543,6 +1543,18 @@ function pfUI.api.BarButtonAnchor(button,basename,buttonindex,barsize,formfactor
return button._anchor return button._anchor
end end
-- [ MouseIsOverHitRect ] --
-- Like MouseIsOver, but tests the frame's hit rect, the area the engine
-- uses for mouse focus and OnEnter/OnLeave. CreateBackdrop widens that
-- rect by the border, so plain MouseIsOver misses a band around the frame.
-- 'frame' the frame to test
-- return true when the cursor is inside the frame's hit rect
function pfUI.api.MouseIsOverHitRect(frame)
if not frame.GetHitRectInsets then return MouseIsOver(frame) end
local left, right, top, bottom = frame:GetHitRectInsets()
return MouseIsOver(frame, -top, bottom, left, -right)
end
-- [ Enable Autohide ] -- -- [ Enable Autohide ] --
-- 'frame' the frame that should be hidden -- 'frame' the frame that should be hidden
function pfUI.api.EnableAutohide(frame, timeout, combat) function pfUI.api.EnableAutohide(frame, timeout, combat)
+2 -2
View File
@@ -661,7 +661,7 @@ function pfUI.api.SkinButton(button, cr, cg, cb, icon, disableHighlight)
end end
b.UnlockHighlight = function() b.UnlockHighlight = function()
if not MouseIsOver(b) then if not MouseIsOverHitRect(b) then
b:SetBackdropBorderColor(GetStringColor(pfUI_config.appearance.border.color)) b:SetBackdropBorderColor(GetStringColor(pfUI_config.appearance.border.color))
end end
b.locked = false b.locked = false
@@ -1175,7 +1175,7 @@ function pfUI.api.CreateInfoBox(text, time, parent, height)
if GetTime() > infobox.lastshow + infobox.duration then if GetTime() > infobox.lastshow + infobox.duration then
if not infobox.fade:IsPlaying() then infobox.fade:Play() end if not infobox.fade:IsPlaying() then infobox.fade:Play() end
elseif MouseIsOver(this) then elseif MouseIsOverHitRect(this) then
this:SetAlpha(max(0.4, this:GetAlpha() - .1)) this:SetAlpha(max(0.4, this:GetAlpha() - .1))
else else
this:SetAlpha(min(1, this:GetAlpha() + .1)) this:SetAlpha(min(1, this:GetAlpha() + .1))
+1 -1
View File
@@ -317,7 +317,7 @@ pfUI:RegisterModule("actionbar", function ()
-- handle button highlight -- handle button highlight
if keystate == "down" then if keystate == "down" then
self.highlight:Show() self.highlight:Show()
elseif not MouseIsOver(self) then elseif not MouseIsOverHitRect(self) then
self.highlight:Hide() self.highlight:Hide()
end end
end end
+5 -5
View File
@@ -176,8 +176,8 @@ pfUI:RegisterModule("equipmentmanager", function()
rowMenu:RegisterEvent("GLOBAL_MOUSE_DOWN") rowMenu:RegisterEvent("GLOBAL_MOUSE_DOWN")
rowMenu:SetScript("OnEvent", function() rowMenu:SetScript("OnEvent", function()
if not this:IsShown() then return end if not this:IsShown() then return end
if MouseIsOver(this) then return end if MouseIsOverHitRect(this) then return end
if this.anchorBtn and MouseIsOver(this.anchorBtn) then return end if this.anchorBtn and MouseIsOverHitRect(this.anchorBtn) then return end
this:Hide() this:Hide()
end) end)
tinsert(UISpecialFrames, "pfEqMgrRowMenu") -- Escape closes it tinsert(UISpecialFrames, "pfEqMgrRowMenu") -- Escape closes it
@@ -313,10 +313,10 @@ pfUI:RegisterModule("equipmentmanager", function()
-- Show the gear and tooltip while the cursor is over the row or its -- Show the gear and tooltip while the cursor is over the row or its
-- gear child. The gear sits inside the row's rectangle, so a single -- gear child. The gear sits inside the row's rectangle, so a single
-- MouseIsOver(row) check covers both. OnLeave on the row and the gear -- MouseIsOverHitRect(row) check covers both. OnLeave on the row and the
-- catches every exit path, so no OnUpdate poll is needed. -- gear catches every exit path, so no OnUpdate poll is needed.
local function HideRowHover() local function HideRowHover()
if MouseIsOver(row) then return end if MouseIsOverHitRect(row) then return end
GameTooltip:Hide() GameTooltip:Hide()
row.gear:Hide() row.gear:Hide()
end end
+3 -2
View File
@@ -58,10 +58,11 @@ pfUI:RegisterModule("gui", function ()
return return
end end
if MouseIsOver(this) and not this.over then local over = MouseIsOverHitRect(this)
if over and not this.over then
this.tex:Show() this.tex:Show()
this.over = true this.over = true
elseif not MouseIsOver(this) and this.over then elseif not over and this.over then
this.tex:Hide() this.tex:Hide()
this.over = nil this.over = nil
end end
+1 -1
View File
@@ -191,7 +191,7 @@ end
local self = self or this local self = self or this
if self.text_mouse == "1" then if self.text_mouse == "1" then
self.bar.text:SetShown(MouseIsOver(self)) self.bar.text:SetShown(self.hover)
end end
if self.always then return end if self.always then return end