scripting: set(): add script flag to prevent script execution
This commit is contained in:
parent
97a754c047
commit
f173bc20d4
5 changed files with 7 additions and 5 deletions
|
|
@ -101,8 +101,9 @@ Returns the value 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. `id` may contains wildcards ('\*').
|
||||
- `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)
|
||||
- `sync: false`: prevents widgets from triggering synchronization and scripts
|
||||
- `script: false`: prevents scripts but not synchronization
|
||||
- `send: false`: prevents widgets from sending osc messages
|
||||
|
||||
Sets the value of the first matching widget. If `ìd` contains wildcards, affects all matching widgets **except** the emitting widget.
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class WidgetManager extends EventEmitter {
|
|||
let v = widget.getValue()
|
||||
for (let i in widgetsByLinkId) {
|
||||
if (widgetsByLinkId[i] !== widget) {
|
||||
widgetsByLinkId[i].setValue(v,{send: options.send,sync: true, id})
|
||||
widgetsByLinkId[i].setValue(v,{send: options.send, sync: true, script:options.script, id})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ class Widget extends EventEmitter {
|
|||
}, builtIn: true, parent: this})
|
||||
this.script._not_editable = true
|
||||
this.on('change', (e)=>{
|
||||
if (e.widget === this && this.mounted && !e.options.fromEdit) {
|
||||
if (e.widget === this && this.mounted && !e.options.fromEdit && e.options.script !== false) {
|
||||
this.script.setValue(e.options.widget ? e.options.widget.value : this.value, {...e.options, id: e.options.id || e.id})
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ class ScriptVm extends Vm {
|
|||
|
||||
if (extraOptions.send === false) options.send = false
|
||||
if (extraOptions.sync === false) options.sync = false
|
||||
if (extraOptions.script === false) options.script = false
|
||||
|
||||
var widgets
|
||||
if (id.includes('*')) {
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ class Script extends Widget {
|
|||
|
||||
setValue(v, options={}) {
|
||||
|
||||
if (this.getProp('event') === 'value') {
|
||||
if (this.getProp('event') === 'value' && options.script !== false) {
|
||||
|
||||
var returnValue = this.run({
|
||||
value: v,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue