Sending on and of state for button

I managed to control a macro inside cubase with a button (visibility for a folder), i was wondering if i made can combine these two buttons in one
2023-01-09 20-31-27

Hi,

I'm not clear on what you're trying to achieve. Are you wanting to create 1 button inside OSC that toggles Show ALL and Show Only HITS?

If so, based on what you have now, you could create a button, and set the mode to toggle. In the onValue scripting property, use the following.

// show only hits
if (value === 1) {
  // target, address, midiChannel, midiAddress, midiValue
  send("midi:OSCtoDAW", "/control", 1, 1, 1)
}

// show all
if (value === 0) {
  // target, address, midiChannel, midiAddress, midiValue
  send("midi:OSCtoDAW", "/control", 1, 2, 1)
}

Cheers,
DMDComposer

Worked perfectly!
Is it possible if i added another button to another folder to deselect the current button ?

1 Like

Hi,

If you create another button, you could set this toggle to the off value, which by default is 0. You just need to replace the REPLACEMEWITHID in the following code.

// idOfWidget, value
set("REPLACEMEWITHID", 0)

Place that in the onValue script property of the new button you create. Then when the button is tapped, it will set the targeted button to the off value.

Now, if your new button is another toggle button. Then just slightly alter the script by checking the on/off value.

if (value === 1) {
    // idOfWidget, value
    set("REPLACEMEWITHID", 0)
}

Cheers,
DMDComposer

Where do i place this within the other code ?

If you wanted to add it to the previous button to turn off a separate button, you could add it like this.

// show only hits
if (value === 1) {
  // target, address, midiChannel, midiAddress, midiValue
  send("midi:OSCtoDAW", "/control", 1, 1, 1)

  // idOfWidget, value
  set("REPLACEMEWITHID", 0)
}

// show all
if (value === 0) {
  // target, address, midiChannel, midiAddress, midiValue
  send("midi:OSCtoDAW", "/control", 1, 2, 1)
}

Else, my example above was describing creating another button to control the original you first described in your first post.

Cheers,
DMDComposer