Skip to content

Commit

Permalink
fix: UI sometimes staying visible when cursor left the window
Browse files Browse the repository at this point in the history
closes #1000
  • Loading branch information
tomasklaen committed Nov 11, 2024
1 parent c59517f commit be52ba2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/uosc/lib/cursor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ local cursor = {
y = math.huge,
hidden = true,
distance = 0, -- Distance traveled during current move. Reset by `cursor.distance_reset_timer`.
hover_raw = false,
last_hover = false, -- Stores `mouse.hover` boolean of the last mouse event for enter/leave detection.
-- Event handlers that are only fired on zones defined during render loop.
---@type {event: string, hitbox: Hitbox; handler: CursorEventHandler}[]
zones = {},
Expand Down Expand Up @@ -401,12 +401,12 @@ end
-- Movement
function handle_mouse_pos(_, mouse)
if not mouse then return end
if cursor.hover_raw and not mouse.hover then
if cursor.last_hover and not mouse.hover then
cursor:leave()
else
elseif not cursor.hidden or not cursor.last_hover and mouse.hover then
cursor:move(mouse.x, mouse.y)
end
cursor.hover_raw = mouse.hover
cursor.last_hover = mouse.hover
end
mp.observe_property('mouse-pos', 'native', handle_mouse_pos)

Expand Down

0 comments on commit be52ba2

Please sign in to comment.