mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-23 20:40:50 +00:00
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:
+12
@@ -1543,6 +1543,18 @@ function pfUI.api.BarButtonAnchor(button,basename,buttonindex,barsize,formfactor
|
||||
return button._anchor
|
||||
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 ] --
|
||||
-- 'frame' the frame that should be hidden
|
||||
function pfUI.api.EnableAutohide(frame, timeout, combat)
|
||||
|
||||
+2
-2
@@ -661,7 +661,7 @@ function pfUI.api.SkinButton(button, cr, cg, cb, icon, disableHighlight)
|
||||
end
|
||||
|
||||
b.UnlockHighlight = function()
|
||||
if not MouseIsOver(b) then
|
||||
if not MouseIsOverHitRect(b) then
|
||||
b:SetBackdropBorderColor(GetStringColor(pfUI_config.appearance.border.color))
|
||||
end
|
||||
b.locked = false
|
||||
@@ -1175,7 +1175,7 @@ function pfUI.api.CreateInfoBox(text, time, parent, height)
|
||||
|
||||
if GetTime() > infobox.lastshow + infobox.duration then
|
||||
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))
|
||||
else
|
||||
this:SetAlpha(min(1, this:GetAlpha() + .1))
|
||||
|
||||
@@ -317,7 +317,7 @@ pfUI:RegisterModule("actionbar", function ()
|
||||
-- handle button highlight
|
||||
if keystate == "down" then
|
||||
self.highlight:Show()
|
||||
elseif not MouseIsOver(self) then
|
||||
elseif not MouseIsOverHitRect(self) then
|
||||
self.highlight:Hide()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -176,8 +176,8 @@ pfUI:RegisterModule("equipmentmanager", function()
|
||||
rowMenu:RegisterEvent("GLOBAL_MOUSE_DOWN")
|
||||
rowMenu:SetScript("OnEvent", function()
|
||||
if not this:IsShown() then return end
|
||||
if MouseIsOver(this) then return end
|
||||
if this.anchorBtn and MouseIsOver(this.anchorBtn) then return end
|
||||
if MouseIsOverHitRect(this) then return end
|
||||
if this.anchorBtn and MouseIsOverHitRect(this.anchorBtn) then return end
|
||||
this:Hide()
|
||||
end)
|
||||
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
|
||||
-- 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
|
||||
-- catches every exit path, so no OnUpdate poll is needed.
|
||||
-- MouseIsOverHitRect(row) check covers both. OnLeave on the row and the
|
||||
-- gear catches every exit path, so no OnUpdate poll is needed.
|
||||
local function HideRowHover()
|
||||
if MouseIsOver(row) then return end
|
||||
if MouseIsOverHitRect(row) then return end
|
||||
GameTooltip:Hide()
|
||||
row.gear:Hide()
|
||||
end
|
||||
|
||||
+3
-2
@@ -58,10 +58,11 @@ pfUI:RegisterModule("gui", function ()
|
||||
return
|
||||
end
|
||||
|
||||
if MouseIsOver(this) and not this.over then
|
||||
local over = MouseIsOverHitRect(this)
|
||||
if over and not this.over then
|
||||
this.tex:Show()
|
||||
this.over = true
|
||||
elseif not MouseIsOver(this) and this.over then
|
||||
elseif not over and this.over then
|
||||
this.tex:Hide()
|
||||
this.over = nil
|
||||
end
|
||||
|
||||
+1
-1
@@ -191,7 +191,7 @@ end
|
||||
local self = self or this
|
||||
|
||||
if self.text_mouse == "1" then
|
||||
self.bar.text:SetShown(MouseIsOver(self))
|
||||
self.bar.text:SetShown(self.hover)
|
||||
end
|
||||
|
||||
if self.always then return end
|
||||
|
||||
Reference in New Issue
Block a user