Custom Module Question

I'm writing a custom module to change 4 button labels by receiving MIDI CCs.

Here is my custom module.

It works fine but I have to write receive messages again and again...

How can I simplify them?

It doesn't look very complicated, but you can define a function that calls receive and use it instead to make things shorter. Note that the comas between the receive() calls is not doing what you think it is (ie putting the calls under the same condition) -> if...else - JavaScript | MDN & Comma operator (,) - JavaScript | MDN

Thank you for your suggestion and pointing it out...!

Now, I want to change the label on each matrix button through custom module, but it doesn't work.

What is wrong with this receive message?

receive('/EDIT', 'matrix_1', {'props':{'label': ["Label A", "Label B"]}})

hi, i have not done this like you, but i think i spotted at least one error. after matrix_1 it should be something like this


i think it should pass a string that is representing an object, not passing an object itself.

Passing plain objects is fine, they are converted to strings automatically. The issue here is that setting props to
{"label": ["Label A", "Label B"]}}
only tells the matrix to set all its children's labels to
["Label A", "Label B"]
The matrix won't dispatch the array's item across the children by itself, you could simply edit the childrens directly (their id is matrix_id/INDEX by default)

Thank you jean-emmanuel and abstrus! I have to read a document more, but now the matrix shows labels correctly!