diff --git a/resources/docs/widgets/inputs.md b/resources/docs/widgets/inputs.md index 4232cdc2..f4c76c59 100644 --- a/resources/docs/widgets/inputs.md +++ b/resources/docs/widgets/inputs.md @@ -89,7 +89,7 @@ - usage: this property is evaluated each time the widgets receives a non-falsy value. [Formulas](../extras/advanced-property-syntax/#formulas) are given extras variables in this context: - `value`: the value received by the widget - `send`: `function` for sending osc messages - - `set`: `function` for setting a widget's value (triggers osc sendings) + - `set`: `function` for setting a widget's value #### `send(target, address, arg1, arg2, ...)` - `target` (`string` or `array` or `false`): one or several osc targets. Default targets (`--send` and the script's `target` property) are ignored unless `target` is `false` @@ -99,4 +99,3 @@ #### `set(id, value, send)` - `id` (`string`): a widget's id - `value`: the widget's new value -- `send` (`boolean`): `true` by default, set to `false` to prevent osc sendings diff --git a/src/browser/js/app/widgets/inputs/script.js b/src/browser/js/app/widgets/inputs/script.js index 05dce4cc..4ba0efe2 100644 --- a/src/browser/js/app/widgets/inputs/script.js +++ b/src/browser/js/app/widgets/inputs/script.js @@ -50,16 +50,13 @@ class Script extends Widget { } - static scriptSet(id, value, send = true) { + static scriptSet(id, value, options) { var widgets = widgetManager.getWidgetById(id) for (var i = widgets.length - 1; i >= 0; i--) { - return widgets[i].setValue(value, { - sync: true, - send: send - }) + return widgets[i].setValue(value, options) } @@ -82,7 +79,14 @@ class Script extends Widget { setValue(v, options={} ) { - if (v) this.resolveProp('script', undefined, false, false, false, {value: v, send: this.scriptSend.bind(this), set: Script.scriptSet, log: console.log}) + var context = { + value: v, + send: options.send ? this.scriptSend.bind(this) : ()=>{}, + set: (id, value)=>{Script.scriptSet(id, value, options)}, + log: console.log + } + + if (v) this.resolveProp('script', undefined, false, false, false, context) // if (options.send) this.sendValue() if (options.sync) this.changed(options)