Matrix button toggle if on or off change props.address

Hi,

In a Matrix Buttons (toggle) i need to define two props.address (to send osc command):

  • if the button is off do this
  • if the button is on do this

Anyone can help me?

in the matrix props i have this code:

JS{{
var props = {}
props.mode = "toggle"
props.label = "Q"+[$+1]
//props.address = "/cue/"+[$+1]+"/sart"
props.on = 1
props.off = 0

//trying to verify the button class selector, but it's not wooking 
if ((".button-container.on")[0]){
    props.address = "/cue/"+[$+1]+"/start"
} else {
    // Do something if class does not exist
    props.address = "/cue/"+[$+1]+"/panic"
}

return props
}}

i made a lot of research in the foruns, but didn't find a solution.

thanks!

Checking the css classes like this is not possible and I wouldn't recommand it anyway since the relevant information here is the button's value. Try this instead:

JS{
var props = {}
props.mode = "toggle"
props.label = "Q"+[$+1]
props.on = 1
props.off = 0
props.bypass = true // prevent sending default messages
props.onValue = `
if (value === 1) send('/cue/' + (getIndex()+1) + '/start', 1)
else send('/cue/' + (getIndex()+1) + '/panic', 0)
`
return props
}

the getIndex()+1 is the key... Thank you so much, it works!