Changing label in matrix button

Hey,
I found an other solution,
but in a matrix button how can we change the label name, and in other way how to access to any parameter like the “mode” type (toggle, push)

Best

tried "mode": "push", in props but that’s not working
edit : it works (I need to go to bed I think)

but still not able to change the label on each button

When dealing with matrices, using JS{{}} is recommended. In the props property an extra variable ($) is available to use the children’s indices:

JS{{
var props = {}
props.mode = "push"
props.label = "button n° " + $ 
return props
}}

Arbitrary property values can be defined too:

JS{{
var props = {}
var labels = ["joe", "william", "jack", "averell"]
props.mode = "push"
props.label = labels[$] 
return props
}}
1 Like

Thank you !!
Working fine, but when adding some parameters to customize midi config all break down.

JS{{
var props = {}
var labels = ["mute", "solo"]
props.mode = "toggle"
props.label = labels[$]
"target": "midi:virtual_midi",
"address": "/control",
"preArgs": [3, #{$+24}]
return props
}}

You’re mixing up the object notation (key: value) and the javascript syntax ("target": "midi:virtual_midi", is not a valid javascript statement), either write

JS{{
var props = {
  "target": "midi:virtual_midi",
  "address": "/control",
  "preArgs": [3, $+24]
}
var labels = ["mute", "solo"]
props.mode = "toggle"
props.label = labels[$]

return props
}}

or

JS{{
var props = {}
var labels = ["mute", "solo"]
props.mode = "toggle"
props.label = labels[$]
props.target = "midi:virtual_midi"
props.address =  "/control"
props.preArgs = [3, $+24]
return props
}}

EDIT: you don’t need to write #{$ + 24} in a JS{{}} block, just $ + 24 (since #{} and JS{{}} are basically the same thing).

1 Like

Both solution are not working, when I only copy the labels part it works fine but when adding the midi one the code seems broken.
I tried to change the code and the curly brackets position but nothing works :confused:

matrix_label.json (3.6 KB)

Sorry I overlooked it, I edited my post.

sorry but when I’m copying the script into props and click on button the script is deleted ?!

Looks like there’s a bug when multiple osc-related properties are overridden at the same time, I’ll get back to you on this soon.

ok thank you

That was a nasty bug : it’s fixed in 1.5.3.

1 Like

thank you :slight_smile:

It’s working perfectly
for other user that will want to use the code, I just added props.on & props.off

JS{{
var props = {}
var labels = ["mute", "solo"]
props.mode = "toggle"
props.label = labels[$]
props.target = "midi:virtual_midi"
props.on = 127
props.off = 0
props.address =  "/control"
props.preArgs = [3, $+24]
return props
}}
1 Like