From a6237a0aac49ccdb1c81becbe4387bb4aad71ba0 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 22 Nov 2023 10:15:40 +0100 Subject: [PATCH] scripting: `stateSet`: add optional `{send: false}` flag --- CHANGELOG.md | 5 +++++ resources/docs/docs/widgets/scripting.md | 5 ++++- src/client/widgets/scripts/script-vm.js | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45e3c4f8..90b76a97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.26.0 + +- scripting + - `stateSet`: add optional `{send: false}` flag + ## 1.25.5 - bug fixes diff --git a/resources/docs/docs/widgets/scripting.md b/resources/docs/docs/widgets/scripting.md index 75f1c7f7..843a4641 100644 --- a/resources/docs/docs/widgets/scripting.md +++ b/resources/docs/docs/widgets/scripting.md @@ -233,10 +233,13 @@ Returns a state object (`id:value`) for matching widget and all their children. ---- -#### `stateSet(state)` +#### `stateSet(state, options)` Loads a state object. If the event that triggered the script's execution was initiated by a user interaction, this will make the updated widgets send their value as well. +- `options` (optional): `object`, accepts the following items: + - `send: false`: prevents widgets from sending osc messages + ---- #### `storage` diff --git a/src/client/widgets/scripts/script-vm.js b/src/client/widgets/scripts/script-vm.js index 83b34dac..028c55a4 100644 --- a/src/client/widgets/scripts/script-vm.js +++ b/src/client/widgets/scripts/script-vm.js @@ -330,12 +330,12 @@ class ScriptVm extends Vm { } - this.sandbox.contentWindow.stateSet = (state)=>{ + this.sandbox.contentWindow.stateSet = (state, extraOptions = {})=>{ this.checkContext('stateSet') var options = this.getValueOptions() - stateManager.set(state, options.send) + stateManager.set(state, extraOptions.send === false ? false : options.send) }