From 0481691c7e29bca7037ffbdc9047c36d7f125865 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Wed, 19 Oct 2022 09:30:14 +0200 Subject: [PATCH] Revert "button: decoupled: fix toggle mode so that it always send requested value" This reverts commit 2f3aab546d466cbaec6c4275b957596a237a879b. --- src/client/widgets/basics/button.js | 34 ++++++++++------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/client/widgets/basics/button.js b/src/client/widgets/basics/button.js index 35ed8a17..0aa0a890 100644 --- a/src/client/widgets/basics/button.js +++ b/src/client/widgets/basics/button.js @@ -165,6 +165,12 @@ class Button extends Widget { if (tap) this.noValueState = true + if (mode === 'momentary') { + this.value = null + } else { + this.value = this.getProp('off') + } + this.label = html`` if (this.getProp('wrap')) this.label.classList.add('wrap') @@ -173,27 +179,8 @@ class Button extends Widget { this.updateLabel() - } - get value() { - - switch (this.getProp('mode')) { - case 'toggle': - if (this.getProp('decoupled')) { - return this.getProp(this.state ? 'off' : 'on') - } else { - return this.getProp(this.state ? 'on' : 'off') - } - case 'push': - return this.getProp(this.active ? 'on' : 'off') - case 'tap': - return this.getProp('on') - case 'momentary': - return null - } - - } setValue(v, options={}) { @@ -222,17 +209,18 @@ class Button extends Widget { if (newstate !== undefined) { + this.state = newstate if (this.getProp('decoupled')) { if (options.fromExternal) { - this.state = newstate this.container.classList.toggle('on', this.state) } } else if (mode === 'toggle' || mode === 'push') { - this.state = newstate this.container.classList.toggle('on', this.state) - } else { - this.state = newstate + } + + if (mode !== 'momentary') { + this.value = this.getProp(this.state ? 'on' : 'off') } if (this.exposeTouchCoords) {