mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-26 21:00:21 +00:00
defaults.lua: support custom arg in mp.add_key_binding()
The information is available in the table.
This commit is contained in:
@@ -316,8 +316,8 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
or pass the ``fn`` argument in place of the name. The latter is not
|
||||
recommended and is handled for compatibility only.)
|
||||
|
||||
The last argument is used for optional flags. This is a table, which can
|
||||
have the following entries:
|
||||
The ``flags`` argument is used for optional parameters. This is a table,
|
||||
which can have the following entries:
|
||||
|
||||
``repeatable``
|
||||
If set to ``true``, enables key repeat for this specific binding.
|
||||
@@ -361,6 +361,11 @@ The ``mp`` module is preloaded, although it can be loaded manually with
|
||||
The scale of the key, such as the ones produced by ``WHEEL_*``
|
||||
keys. The scale is 1 if the key is nonscalable.
|
||||
|
||||
``arg``
|
||||
User-provided string in the ``arg`` argument in the
|
||||
``script-binding`` command if the key binding is invoked
|
||||
by that command.
|
||||
|
||||
Internally, key bindings are dispatched via the ``script-message-to`` or
|
||||
``script-binding`` input commands and ``mp.register_script_message``.
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ local function reserve_binding()
|
||||
return "__keybinding" .. tostring(message_id)
|
||||
end
|
||||
|
||||
local function dispatch_key_binding(name, state, key_name, key_text, scale)
|
||||
local function dispatch_key_binding(name, state, key_name, key_text, scale, arg)
|
||||
local fn = dispatch_key_bindings[name]
|
||||
if fn then
|
||||
fn(name, state, key_name, key_text, scale)
|
||||
fn(name, state, key_name, key_text, scale, arg)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -201,7 +201,7 @@ local function add_binding(attrs, key, name, fn, rp)
|
||||
["r"] = "repeat",
|
||||
["p"] = "press",
|
||||
}
|
||||
key_cb = function(_, state, key_name, key_text, scale)
|
||||
key_cb = function(_, state, key_name, key_text, scale, arg)
|
||||
if key_text == "" then
|
||||
key_text = nil
|
||||
end
|
||||
@@ -212,6 +212,7 @@ local function add_binding(attrs, key, name, fn, rp)
|
||||
key_name = key_name,
|
||||
key_text = key_text,
|
||||
scale = tonumber(scale),
|
||||
arg = arg,
|
||||
})
|
||||
end
|
||||
msg_cb = function()
|
||||
|
||||
Reference in New Issue
Block a user