push: force release when widget is removed/recreated, prevent setting active state after editing

This commit is contained in:
bordun 2019-07-19 11:57:26 +02:00
parent b9293786b6
commit 2414722ea1
3 changed files with 16 additions and 8 deletions

View file

@ -6,7 +6,9 @@
- midi: `path` option not applied to launcher's `list` contextual action
- midi: pitchbend messages not received correctly
- style: layout issues in recent chromium
- encoder: `0` value in `back` property not working
- encoder: `0` value in `back` property not working
- editor: state not completely restored under some conditions
- push: force release when the widget is removed/recreated while pressed
## 0.47.1
@ -34,7 +36,6 @@
- script: `get(id)` function added in `script`execution context
- script: `getProp(id, property)` function added in `script`execution context
- script: `id` variable added in `script`execution context (id of the widget that triggered the script)
- editor: state not completely restored under some conditions
## 0.46.1

View file

@ -63,7 +63,7 @@ var StateManager = class StateManager {
if (widgets[j].setValue) {
widgets[j].setValue(value, {send:send,sync:true})
widgets[j].setValue(value, {send:send, sync:true, fromState:true})
}
@ -216,7 +216,7 @@ var StateManager = class StateManager {
preset[id] = w.getProp('value')
}
}
this.set(preset)
this.valueStateQueue = {}

View file

@ -32,7 +32,7 @@ class Push extends Widget {
super({...options, html: html`<div class="toggle"></div>`})
this.state = 0
this.active = 0
this.active = null
this.lastChanged = 'state'
if (this.getProp('doubleTap')) {
@ -76,7 +76,7 @@ class Push extends Widget {
if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) {
this.widget.classList.add('active')
this.container.classList.add('active')
this.active = 1
this.active = options
this.lastChanged = 'active'
this.updateValue()
if (options.send) this.sendValue()
@ -84,7 +84,7 @@ class Push extends Widget {
} else if (v===this.getProp('off') || (this.getProp('off') != null && v === this.getProp('off').value && v !== undefined)) {
this.widget.classList.remove('active')
this.container.classList.remove('active')
this.active = 0
this.active = null
this.lastChanged = 'active'
this.updateValue()
if (options.send) this.sendValue(null, {syncOnly: this.getProp('norelease')})
@ -96,9 +96,10 @@ class Push extends Widget {
setValue(v,options={}) {
if (!options.fromExternal) {
this.setValuePrivate(v,options)
if (!options.fromState) this.setValuePrivate(v,options)
return
}
if (typeof v == 'object' && v !== null) v = v.value
if (v===this.getProp('on') || (this.getProp('on') != null && v === this.getProp('on').value && v !== undefined)) {
this.widget.classList.add('on')
@ -135,6 +136,12 @@ class Push extends Widget {
}
onRemove() {
if (this.active) this.setValuePrivate(this.getProp('off'), this.active)
super.onRemove()
}
}
Push.dynamicProps = Push.prototype.constructor.dynamicProps.concat(