keyboard: incoming values different than the off property are now interpreted as on

This commit is contained in:
jean-emmanuel 2023-03-10 11:18:09 +01:00
parent 8546ce6dee
commit 3a9882313c
2 changed files with 7 additions and 5 deletions

View file

@ -6,6 +6,9 @@
- linkId not working between two encoder widgets
- fader: `gradient` breakpoints not positioned correctly
- widgets
- keyboard: incoming values different than the `off` property are now interpreted as `on`
- editor
- when focusing the label property with `F2`, select all text in the text area
- preserve scroll position in code editor when validating

View file

@ -46,7 +46,7 @@ class Keyboard extends Panel {
value: {
value: {type: 'array', value: '', help: [
'The keyboard widget accepts the following values:',
'- a `[note, value]` array to set the value of a single key where `note` is the note number and `value` is equal to the `on` or `off` property.',
'- a `[note, value]` array to set the value of a single key where `note` is the note number and `value` depends on the `on` and `off` properties (any value different from `off` will be interpreted as `on`).',
'- an array of values with one item per key in the keyboard'
]}
},
@ -164,18 +164,17 @@ class Keyboard extends Panel {
if (v.length === this.children.length) {
for (var i = 0; i < this.children.length; i++){
this.children[i].setValue(v[i] === this.getProp('on') ? 1 : 0, options)
this.children[i].setValue(v[i] !== this.getProp('off') ? 1 : 0, options)
}
}
else if (
v.length === 2 &&
v[0] >= parseInt(this.getProp('start')) && v[0] < 128 &&
(v[1] === this.getProp('on') || v[1] === this.getProp('off'))
v[0] >= parseInt(this.getProp('start')) && v[0] < 128
) {
var index = v[0] - parseInt(this.getProp('start'))
if (this.children[index]) {
this.children[index].setValue(v[1] === this.getProp('on') ? 1 : 0, options)
this.children[index].setValue(v[1] !== this.getProp('off') ? 1 : 0, options)
}
}