scripting: calling setFocus() without if now unfocuses active element

This commit is contained in:
jean-emmanuel 2025-12-14 14:41:05 +01:00
parent 42b71ef6fc
commit 31f4119442
3 changed files with 4 additions and 1 deletions

View file

@ -28,6 +28,7 @@
- user scripts are longer protected against infinite loop and the main window object may be reached (it's not supported to break out of scripting context, but resources are no longer wasted to prevent it)
- `toolbar()` can now target menu actions by id instead of index
- `getToolbar()` function added (returns the state of a menu entry toggle)
- calling `setFocus()` without argument now unfocuses current active element
- midi
- add `no_auto_note_off` option

View file

@ -303,7 +303,7 @@ Reference:
- `id` (optional): widget `id` as a string
Gives focus to a widget (ie input widget).
Gives focus to a widget (ie input widget). If `id` is omitted or falsy, currently focused element will be unfocused.
*Built-in client only*: tells the operating system to give the focus to the client window

View file

@ -452,6 +452,8 @@ class ScriptVm extends Vm {
if (widgets.length) {
if (widgets[0].focus) widgets[0].focus()
}
} else if (document.activeElement) {
document.activeElement.blur()
}
// built-in client only: electron will call window.focus()