From 7b916d34e8116a1837a5511ec32fa29490fefd0e Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Wed, 21 Jan 2026 22:09:53 -0800 Subject: add hover state for menu --- main.lua | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'main.lua') diff --git a/main.lua b/main.lua index 0ee88c7..f3a1915 100644 --- a/main.lua +++ b/main.lua @@ -1005,9 +1005,13 @@ local function handle_mouse_click(ev, id) return end + local mpos = osd.mpos + if not mpos then + return + end + local time = mp.get_time() local clk = click_state - local mpos = osd.mpos if ev.event == 'down' then clk.ct, clk.ck = time, ev.key_name @@ -1240,19 +1244,30 @@ local function handle_key(ev) t = binding_state.active['ANY_UNICODE'] end + -- ev.is_mouse is false for some mouse events + local k = ev.key_name + if k:find('MOUSE_') or k:find('MBTN_') or k:find('WHEEL_') then + if not osd.mactive then + osd:set_mactive(true) + end + elseif osd.mactive then + osd:set_mactive(false) + click_state = {} + end + local f = t and t[1] if not f then - return + goto flush end - local flag = t[2] - if flag == 'complex' then + if t[2] == 'complex' then f(ev) elseif ev.event == 'down' or - (ev.event == 'repeat' and flag == 'repeat') then + (ev.event == 'repeat' and t[2] == 'repeat') then f() end + ::flush:: osd:flush(state) end @@ -1365,6 +1380,8 @@ mp.observe_property('mouse-pos', 'native', function(_, mpos) else btn_timer:kill() end + + osd:flush(state) end) mp.observe_property('user-data/osc/visibility', 'native', function(_, val) -- cgit v1.2.3-70-g09d2