switch: make values prop dynamic
This commit is contained in:
parent
414195c621
commit
80e5b048ea
3 changed files with 22 additions and 3 deletions
|
|
@ -21,6 +21,7 @@
|
|||
- input: add `noCanvas` option to avoid blurry text under some circumstances
|
||||
- xy: add `clipX` and `clipY` proprties (allows multixy to set per-pads anges limits)
|
||||
- button: add `onTouch` script
|
||||
- switch: make `values` property dynamic
|
||||
|
||||
- editor
|
||||
- selecting a widget automatically shows it in the widget tree if it's not minimized
|
||||
|
|
|
|||
|
|
@ -84,8 +84,6 @@ class Dropdown extends MenuBase {
|
|||
`)
|
||||
}
|
||||
|
||||
this.setValue(this.value)
|
||||
|
||||
}
|
||||
|
||||
setValue(v,options={}) {
|
||||
|
|
@ -121,7 +119,6 @@ class Dropdown extends MenuBase {
|
|||
|
||||
case 'values':
|
||||
this.parseValues()
|
||||
this.setValue(this.value)
|
||||
return
|
||||
case 'label':
|
||||
this.setLabel()
|
||||
|
|
|
|||
|
|
@ -108,6 +108,8 @@ class Switch extends MenuBase {
|
|||
|
||||
super.parseValues()
|
||||
|
||||
this.widget.innerHTML = ''
|
||||
|
||||
for (var i = 0; i < this.values.length; i++) {
|
||||
|
||||
this.widget.appendChild(html`
|
||||
|
|
@ -116,6 +118,8 @@ class Switch extends MenuBase {
|
|||
|
||||
}
|
||||
|
||||
this.setValue(this.value)
|
||||
|
||||
}
|
||||
|
||||
setValue(v, options={}) {
|
||||
|
|
@ -135,6 +139,19 @@ class Switch extends MenuBase {
|
|||
|
||||
}
|
||||
|
||||
onPropChanged(propName, options, oldPropValue) {
|
||||
|
||||
var ret = super.onPropChanged(...arguments)
|
||||
|
||||
switch (propName) {
|
||||
|
||||
case 'values':
|
||||
this.parseValues()
|
||||
}
|
||||
|
||||
return ret
|
||||
|
||||
}
|
||||
setCssVariables() {
|
||||
|
||||
super.setCssVariables()
|
||||
|
|
@ -144,6 +161,10 @@ class Switch extends MenuBase {
|
|||
}
|
||||
}
|
||||
|
||||
Switch.dynamicProps = Switch.prototype.constructor.dynamicProps.concat(
|
||||
'values'
|
||||
)
|
||||
|
||||
Switch.cssVariables = Switch.prototype.constructor.cssVariables.concat(
|
||||
{js: 'colorTextOn', css: '--color-text-on'}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue