From 6b37c4521e26784bd7fb2bd5adc0d3024d40d44c Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 2 Mar 2026 10:37:29 +0100 Subject: [PATCH] button: add `click` option & add missing move events to onTouch --- src/client/widgets/basics/button.mjs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/client/widgets/basics/button.mjs b/src/client/widgets/basics/button.mjs index ae048a66..c1f1ca23 100644 --- a/src/client/widgets/basics/button.mjs +++ b/src/client/widgets/basics/button.mjs @@ -45,6 +45,7 @@ class Button extends Widget { '- `tap` (no release, sends `on` as value)', ]}, doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the button require a double tap to be pushed instead of a single tap'}, + click: {type: 'boolean', value: false, help: 'Set to `true` to activate upon click event instead of tap'}, decoupled: {type: 'boolean', value: false, help: [ 'Set to `true` make the local feedback update only when it receives a value from an osc/midi message that matches the `on` or `off` property.', 'When `decoupled`, the button\'s value is ambiguous: when interacted with, it will send the value that\'s requested (`on` or `off` for `toggle` and `push` modes, `on` for `tap` mode, `null` for `momentary`), otherwise it will return the value received from the feedback message (`on` or `off` property).', @@ -93,7 +94,8 @@ class Button extends Widget { var mode = this.getProp('mode'), tap = mode === 'momentary' || mode === 'tap', - push = mode === 'push' || tap + push = mode === 'push' || tap, + click = this.getProp('click') && mode !== 'push' if (push) { @@ -111,11 +113,11 @@ class Button extends Widget { if (tap) this.container.classList.add('active') - }, {element: this.container}) + }, {element: this.container, click: click}) } else { - this.on('draginit',(e)=>{ + this.on(click ? 'click': 'draginit',(e)=>{ if (this.touchActive) return @@ -167,11 +169,11 @@ class Button extends Widget { this.touchActive = true this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true, y: e.offsetY, x: e.offsetX, local:true}) - }, {element: this.container}) + }, {element: this.container, click: click}) } else { - this.on('draginit',(e)=>{ + this.on(click ? 'click': 'draginit',(e)=>{ if (this.touchActive) return @@ -227,6 +229,7 @@ class Button extends Widget { } if (this.getProp('onTouch')) { + this.on('drag',(e)=>this.onTouch(e, 'move'), {element: this.container}) this.on('dragend',(e)=>this.onTouch(e, 'stop'), {element: this.container}) }