From 919678fea92949f244fc4df1164e72c9c0d8e145 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 19 Oct 2022 11:08:34 +0200 Subject: [PATCH] button: expose locals.external --- src/client/widgets/basics/button.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/widgets/basics/button.js b/src/client/widgets/basics/button.js index 42185ca7..b7750fb2 100644 --- a/src/client/widgets/basics/button.js +++ b/src/client/widgets/basics/button.js @@ -54,7 +54,8 @@ class Button extends Widget { defaults.scripting.onValue.help.push( 'Additional variables:', - '- `locals.touchCoords`: `[x, y]` array representing the touch coordinates, normalized between 0 and 1.' + '- `locals.touchCoords`: `[x, y]` array representing the touch coordinates, normalized between 0 and 1.', + '- `locals.external`: `true` if value was received from an osc/midi message, `false otherwise`.' ) return defaults @@ -71,6 +72,7 @@ class Button extends Widget { this.buttonSize = [100, 100] this.exposeTouchCoords = String(this.getProp('onValue')).includes('touchCoords') + this.parsersLocalScope.external = false this.parsersLocalScope.touchCoords = [0.5, 0.5] if (this.exposeTouchCoords) { this.on('resize', (e)=>{ @@ -246,6 +248,8 @@ class Button extends Widget { if (newstate !== undefined) { + this.parsersLocalScope.external = !!options.fromExternal + if (this.getProp('mode') === 'decoupled') { if (options.fromExternal) {