Skip to content

Commit 9f93c34

Browse files
TimMenu/Widgets/Tooltip: fixed bug where tolltip showed from below dropdown or combo
1 parent d5c7010 commit 9f93c34

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

TimMenu/Widgets/Tooltip.lua

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,23 @@ local Tooltip = {}
77
-- Store tooltip data per window and widget
88
local tooltipData = {}
99

10+
local function pointInBounds(bounds, x, y)
11+
return x >= bounds.x and x <= bounds.x + bounds.w and y >= bounds.y and y <= bounds.y + bounds.h
12+
end
13+
14+
local function isBlockedByPopup(win, x, y)
15+
local blockedRegions = win._widgetBlockedRegions
16+
if not blockedRegions then
17+
return false
18+
end
19+
for _, region in ipairs(blockedRegions) do
20+
if pointInBounds(region, x, y) then
21+
return true
22+
end
23+
end
24+
return false
25+
end
26+
1027
--- Wraps text to multiple lines with a maximum line length
1128
---@param text string The text to wrap
1229
---@param maxLength number Maximum characters per line (default 40)
@@ -130,12 +147,13 @@ function Tooltip.ProcessWindowTooltips(win)
130147
local widgetBounds = win._widgetBounds and win._widgetBounds[widgetIndex]
131148
if widgetBounds then
132149
-- Check if mouse is hovering this widget
133-
local inBounds = mouseX >= widgetBounds.x
134-
and mouseX <= widgetBounds.x + widgetBounds.w
135-
and mouseY >= widgetBounds.y
136-
and mouseY <= widgetBounds.y + widgetBounds.h
150+
local inBounds = pointInBounds(widgetBounds, mouseX, mouseY)
137151

138152
if inBounds then
153+
if isBlockedByPopup(win, mouseX, mouseY) then
154+
-- Popup covers this point; suppress tooltip for underlying widgets
155+
goto continue
156+
end
139157
-- Check if this widget is not blocked by a higher window
140158
local Utils = require("TimMenu.Utils")
141159
if not Utils.IsPointBlocked(TimMenuGlobal.order, TimMenuGlobal.windows, mouseX, mouseY, win.id) then
@@ -163,6 +181,7 @@ function Tooltip.ProcessWindowTooltips(win)
163181
end
164182
end
165183
end
184+
::continue::
166185
end
167186
end
168187

0 commit comments

Comments
 (0)