Revert "button: decoupled: fix toggle mode so that it always send requested value"
This reverts commit 2f3aab546d.
This commit is contained in:
parent
2f3aab546d
commit
0481691c7e
1 changed files with 11 additions and 23 deletions
|
|
@ -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`<label></label>`
|
||||
|
||||
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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue