From e07322a520ea439cb3721457528f616e08d143d1 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 18 Oct 2022 10:18:50 +0200 Subject: [PATCH] button: add client option `altTraversing` to allow one-way response to traversing gestures --- CHANGELOG.md | 4 +++- resources/docs/docs/client-options.md | 1 + src/client/globals.js | 3 +++ src/client/widgets/basics/button.js | 8 ++++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bba59ad..a2de4f32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - widgets - button: add `decoupled` property (restrict visual feedback to values received from osc/midi messages) + - button: add client option `altTraversing` to allow one-way response to traversing gestures - canvas: iOS: trigger `onTouch` when `event.force`, `event.altitudeAngle` or `event.azimuthAngle` updates - knob: add `snap-alt` mode (snap mode that allows jumping between range.min and range.max) - all: add `borderRadius` property @@ -18,7 +19,8 @@ - on Mac, name virtual ports after the device name to avoid confusion - server - - client-options: add `client-sync` option to allow disabling client synchronization + - client-options: add `clientSync` option to allow disabling client synchronization + - client-options: add `altTraversing` option ## 1.17.0 diff --git a/resources/docs/docs/client-options.md b/resources/docs/docs/client-options.md index 7f399a4d..17fbae66 100644 --- a/resources/docs/docs/client-options.md +++ b/resources/docs/docs/client-options.md @@ -15,6 +15,7 @@ Client options can be set either with the server's `--client-options` option, or | usePercents | 1 / 0 | 0 | sets the editor's "relative units" option | | noFocus | 1 / 0 | 0 | (built-in client only) prevent the client window from taking focus unless a text input or a dropdown is clicked | | clientSync | 1 / 0 | 1 | set to 0 to prevent the client from syncing with other clients | +| altTraversing | 1 / 0 | 0 | set to 1 to enable an alternative traversing behavior for toggle buttons (traversing gestures on toggle buttons will change their values in only one way depending on the first touched button's state) | Example: diff --git a/src/client/globals.js b/src/client/globals.js index d502a499..b8cfb7d3 100644 --- a/src/client/globals.js +++ b/src/client/globals.js @@ -32,6 +32,9 @@ window.CLIENT_SYNC = parseInt(ENV.clientSync) === 0 ? 0 : 1 window.IOS_TOUCH_POLLING = false +window.TOGGLE_ALT_TRAVERSING = ENV.altTraversing ? true : false + + window.JSON.parseFlex = require('json5').parse window.DOM = require('./dom') diff --git a/src/client/widgets/basics/button.js b/src/client/widgets/basics/button.js index 14345706..0aa0a890 100644 --- a/src/client/widgets/basics/button.js +++ b/src/client/widgets/basics/button.js @@ -140,6 +140,14 @@ class Button extends Widget { if (this.active) return + if (e.traversingStack && TOGGLE_ALT_TRAVERSING) { + if (e.traversingStack.firstButtonValue === undefined) { + e.traversingStack.firstButtonValue = this.state + } else if (e.traversingStack.firstButtonValue !== this.state) { + return + } + } + this.active = true this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true, y: e.offsetY, x: e.offsetX})