Skip to content

Commit f2a8f61

Browse files
TimMenu: fixed hover bug
1 parent 062c40b commit f2a8f61

3 files changed

Lines changed: 29 additions & 8 deletions

File tree

TimMenu/Utils.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function Utils.IsPointBlocked(order, windows, x, y, currentWindowKey)
2929
break
3030
end
3131
local win = windows[key]
32-
if win and win.visible and Utils.IsMouseOverWindow(win, x, y) then
32+
if win and win.visible and win:_HitTest(x, y) then
3333
return true
3434
end
3535
end
@@ -40,7 +40,7 @@ function Utils.GetWindowUnderMouse(order, windows, x, y)
4040
for i = #order, 1, -1 do
4141
local key = order[i]
4242
local win = windows[key]
43-
if win and Utils.IsMouseOverWindow(win, x, y) then
43+
if win and win:_HitTest(x, y) then
4444
input.SetMouseInputEnabled(false)
4545
return key
4646
end

TimMenu/Widgets/TextInput.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ for i = 0, 9 do
2020
local key = _G["KEY_" .. i]
2121
if key then
2222
local shifted = string.char(41 + i) -- )!@#$%^&*(
23-
if i == 0 then shifted = ")" end
23+
if i == 0 then
24+
shifted = ")"
25+
end
2426
KeyCodeToCharTable[key] = { tostring(i), shifted }
2527
end
2628
end
@@ -84,8 +86,11 @@ local function handleKeyRepeat(entry, keyCode, currentTime, action)
8486
action()
8587
state.firstDownTime = currentTime
8688
state.lastRepeatTime = currentTime
87-
elseif state.firstDownTime and (currentTime - state.firstDownTime > KEY_REPEAT_INITIAL_DELAY)
88-
and (currentTime - state.lastRepeatTime > KEY_REPEAT_INTERVAL) then
89+
elseif
90+
state.firstDownTime
91+
and (currentTime - state.firstDownTime > KEY_REPEAT_INITIAL_DELAY)
92+
and (currentTime - state.lastRepeatTime > KEY_REPEAT_INTERVAL)
93+
then
8994
action()
9095
state.lastRepeatTime = currentTime
9196
end

TimMenu/Window.lua

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,27 @@ function Window:QueueDrawAtLayer(layer, drawFunc, ...)
6868
DrawManager.Enqueue(self.id, layer, drawFunc, ...)
6969
end
7070

71-
--- Hit test: is a point inside this window (including title bar and content area)?
71+
--- Hit test: is a point inside this window (including title bar, content area, and popups)?
7272
function Window:_HitTest(x, y)
73-
-- Hit test entire window area (title and content)
73+
-- Basic window bounds (title and content)
7474
local titleHeight = Globals.Defaults.TITLE_BAR_HEIGHT
75-
return x >= self.X and x <= self.X + self.W and y >= self.Y and y <= self.Y + titleHeight + self.H
75+
local basicBounds = x >= self.X and x <= self.X + self.W and y >= self.Y and y <= self.Y + titleHeight + self.H
76+
77+
-- If basic bounds pass, return true
78+
if basicBounds then
79+
return true
80+
end
81+
82+
-- Check if point is in any widget blocked regions (popups)
83+
if self._widgetBlockedRegions then
84+
for _, region in ipairs(self._widgetBlockedRegions) do
85+
if x >= region.x and x <= region.x + region.w and y >= region.y and y <= region.y + region.h then
86+
return true
87+
end
88+
end
89+
end
90+
91+
return false
7692
end
7793

7894
--- Update window logic: dragging only; mark touched only in Begin()

0 commit comments

Comments
 (0)