diff options
| author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-12-22 16:14:22 -0800 |
|---|---|---|
| committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2025-12-22 16:14:22 -0800 |
| commit | 67a9492bf2f7b6c42cc056b5ec0e3374ea4a78b0 (patch) | |
| tree | 2cc54efd20b3186b63ce1af1522988cbbffffa14 /main.lua | |
| parent | 798180a818abd5ef608ae491c2ae2109b6e3e9c8 (diff) | |
| download | mpv-iptv-menu-67a9492bf2f7b6c42cc056b5ec0e3374ea4a78b0.tar.gz mpv-iptv-menu-67a9492bf2f7b6c42cc056b5ec0e3374ea4a78b0.tar.xz | |
disable builtin keys while menu is open
Diffstat (limited to 'main.lua')
| -rw-r--r-- | main.lua | 35 |
1 files changed, 26 insertions, 9 deletions
@@ -1336,6 +1336,26 @@ function bind_menu_keys() bind_key('PGDWN', cursor_page_down, {repeatable = true}) end +-- uses enable-section and disable-section to disable builtin key bindings +-- while the OSD is visible. these commands are technically deprecated for +-- non-internal use, but they still work, and there doesn't appear to be +-- another way apart from setting an override for each individual key. +-- +-- might eventually change this to a selective override, since some of these +-- builtin keys could still be useful while the menus are open. +local function set_key_bindings() + if osd.hidden then + unbind_keys() + mp.command_native({'enable-section', 'default'}) + elseif menus[depth].search_active then + bind_search_keys() + mp.command_native({'disable-section', 'default'}) + else + bind_menu_keys() + mp.command_native({'disable-section', 'default'}) + end +end + local function toggle_menu() osd.hidden = not osd.hidden osd:update() @@ -1351,13 +1371,7 @@ local function toggle_menu() end end - if osd.hidden then - unbind_keys() - elseif menus[depth].search_active then - bind_search_keys() - else - bind_menu_keys() - end + set_key_bindings() end mp.observe_property('osd-dimensions', 'native', function(_, val) @@ -1378,7 +1392,10 @@ mp.register_event('end-file', function() update_osd() end) -mp.add_forced_key_binding('TAB', 'toggle-menu', toggle_menu) -bind_menu_keys() load_data() push_group_menu(objects['root']) + +-- keys added via bind_key() are unbound when the OSD is closed, but we want +-- toggle-menu to work regardless of setting. +mp.add_forced_key_binding('TAB', 'toggle-menu', toggle_menu) +set_key_bindings() |
