History

js: complex key-binding: send also key_text

This is doumented and has been part of the table in lua, but until now not in the JS object. Fixes #13448

Avi Halachmi (:avih) committed 2 years ago

Commit d70c77b1 parent a45518c1 file · +5 −4Browse files

Showing the changes to player/javascript (1 of 1 file). Show all

Unified · Split

player/javascript/defaults.js+5−4
@@ -246,10 +246,10 @@ mp.get_osd_margins = function get_osd_margins() { · 245 unmodified lines
246// {cb: fn, forced: bool, maybe input: str, repeatable: bool, complex: bool}246// {cb: fn, forced: bool, maybe input: str, repeatable: bool, complex: bool}
247var binds = new_cache();247var binds = new_cache();
248 248
249function dispatch_key_binding(name, state, key_name) {249function dispatch_key_binding(name, state, key_name, key_text) {
250 var cb = binds[name] ? binds[name].cb : false;250 var cb = binds[name] ? binds[name].cb : false;
251 if (cb) // "script-binding [<script_name>/]<name>" command was invoked251 if (cb) // "script-binding [<script_name>/]<name>" command was invoked
252 cb(state, key_name);252 cb(state, key_name, key_text);
253}253}
254 254
255var binds_tid = 0; // flush timer id. actual id's are always true-thy255var binds_tid = 0; // flush timer id. actual id's are always true-thy
@@ -307,11 +307,12 @@ function add_binding(forced, key, name, fn, opts) { · 51 unmodified lines
307 fn({event: "press", is_mouse: false});307 fn({event: "press", is_mouse: false});
308 });308 });
309 var KEY_STATES = { u: "up", d: "down", r: "repeat", p: "press" };309 var KEY_STATES = { u: "up", d: "down", r: "repeat", p: "press" };
310 key_data.cb = function key_cb(state, key_name) {310 key_data.cb = function key_cb(state, key_name, key_text) {
311 fn({311 fn({
312 event: KEY_STATES[state[0]] || "unknown",312 event: KEY_STATES[state[0]] || "unknown",
313 is_mouse: state[1] == "m",313 is_mouse: state[1] == "m",
314 key_name: key_name || undefined314 key_name: key_name || undefined,
315 key_text: key_text || undefined
315 });316 });
316 }317 }
317 } else {318 } else {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t