- set(): add supports for wildcards in the id parameter
- `set()`: add a 3rd optional parameter for preventing further script executions and/or osc messages from being sent
This commit is contained in:
parent
afab7f1b6a
commit
e4be5de318
3 changed files with 37 additions and 13 deletions
|
|
@ -4,7 +4,11 @@
|
|||
|
||||
- widgets
|
||||
- all: add `html` property to allow inserting custom content in widgets (label, value, etc) and style it with the `css` property.
|
||||
- scripting: `send()` now ignores the widget's `bypass` property (allows bypassing default messages and define custom ones).
|
||||
|
||||
- scripting:
|
||||
- `send()`: ignore the widget's `bypass` property (allows bypassing default messages and define custom ones)
|
||||
- `set()`: add supports for wildcards in the id parameter
|
||||
- `set()`: add a 3rd optional parameter for preventing further script executions and/or osc messages from being sent
|
||||
|
||||
- custom module
|
||||
- automatically reload custom module when the file is modified
|
||||
|
|
|
|||
|
|
@ -62,12 +62,15 @@ Returns the value of the first matching widget.
|
|||
|
||||
----
|
||||
|
||||
#### `set(id, value)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
#### `set(id, value, options)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget. `id` can contains wildcards ('\*'), in which case all matching widgets will be affected **except** the emitting widget.
|
||||
- `value`: new value for the widget.
|
||||
- `options` (optional): `object`, accepts the following items:
|
||||
- `sync: false` (prevents widgets from triggering synchronization and scripts)
|
||||
- `send: false` (prevents widgets from sending osc messages)
|
||||
|
||||
Sets the value of the first matching widget.
|
||||
If the event that triggered the script's execution was initiated by a user interaction, this will make the widget send its value as well.
|
||||
Sets the value of matching widgets.
|
||||
If the event that triggered the script's execution was initiated by a user interaction, this will make the widget send its value as well (unless `options` is set to `{send: false}`).
|
||||
|
||||
----
|
||||
|
||||
|
|
@ -76,6 +79,8 @@ If the event that triggered the script's execution was initiated by a user inter
|
|||
- `address`: osc address, must start with a `/`
|
||||
- `args`: value or `{type: "OSC_TYPE_LETTER", value: VALUE}` `object`
|
||||
|
||||
Sends an osc message.
|
||||
|
||||
If the event that triggered the script's execution was not initiated by a user interaction, this function will have no effect.
|
||||
|
||||
This function ignores the widget's `bypass` property.
|
||||
|
|
@ -94,7 +99,7 @@ Returns the property called `"name"` of the first matching widget.
|
|||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
- `name`: property name.
|
||||
|
||||
Forcers a widget to check if one of its properties has changed and update itself if needed.
|
||||
Forces a widget to check if one of its properties has changed and update itself if needed.
|
||||
|
||||
----
|
||||
|
||||
|
|
@ -175,9 +180,11 @@ Sets the scroll state of a container.
|
|||
#### `toolbar(i1, i2, ...)`
|
||||
- `iX`: menu entry index
|
||||
|
||||
Trigger toolbar action at specified index. Examples:
|
||||
Trigger toolbar action at specified index.
|
||||
|
||||
- `toolbar(0, 0)` -> Open a new session
|
||||
- `toolbar(3)` -> Toggle full screen
|
||||
!!! example "Examples"
|
||||
|
||||
Actions will only be triggered if initiated with a user interaction. Fullscreen cannot be toggled with a simulated interaction (i.e. using `/SET`)
|
||||
- `toolbar(0, 0)` -> Open a new session
|
||||
- `toolbar(3)` -> Toggle full screen
|
||||
|
||||
Actions will only be triggered if initiated with a user interaction. Fullscreen cannot be toggled with a simulated interaction (i.e. using `/SET`)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class ScriptVm extends Vm {
|
|||
|
||||
super.registerGlobals()
|
||||
|
||||
this.sandbox.contentWindow.set = (id, value)=>{
|
||||
this.sandbox.contentWindow.set = (id, value, extraOptions = {send: true, sync: true})=>{
|
||||
|
||||
var options = this.getValueOptions()
|
||||
options.fromScript = true
|
||||
|
|
@ -67,11 +67,24 @@ class ScriptVm extends Vm {
|
|||
// if (id === options.id) options.sync = false // loop stop
|
||||
// if (this.getWidget() === options.widget) options.sync = false // loop stop
|
||||
|
||||
var widgets = this.resolveId(id)
|
||||
if (extraOptions.send === false) options.send = false
|
||||
if (extraOptions.sync === false) options.sync = false
|
||||
|
||||
var widgets
|
||||
if (id.includes('*')) {
|
||||
var widget = this.getWidget()
|
||||
if (widget.builtIn) widget = widget.parent
|
||||
widgets = this.resolveId(
|
||||
Object.keys(widgetManager.idRoute).filter(key => key.match(new RegExp('^' + id.replace(/\*/g, '.*') + '$')))
|
||||
).filter(w => w !== widget)
|
||||
} else {
|
||||
widgets = this.resolveId(id)
|
||||
}
|
||||
|
||||
|
||||
for (var i = widgets.length - 1; i >= 0; i--) {
|
||||
|
||||
return widgets[i].setValue(value, options)
|
||||
widgets[i].setValue(value, options)
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue