Home › Forums › General › Programming › Radio button in a modulator group needs a default setting › Reply To: Radio button in a modulator group needs a default setting
Hi Dnaldoog,
Thanks for the reply, I checked your exemple panel and it’s exactly what I want, same for the one you put on your JD990.
I saw that on your tone selector in the JD990 you used the method on valueChange and in the exemple panel you assigned the method to onClick
Can you explain me the difference and the benefits?
I also cannot manage to make this script work on mine since it’s uiImageButton and not uiButton maybe it’s a bug from ctrlr for mac or my script is wrong, even with a striped down version to check onclick I don’t get anything in the console :
UnitSelect = function(--[[ CtrlrComponent --]] comp, --[[ MouseEvent --]] event)
console("Test Script UnitSelect")
end
Here’s my “intended” script:
--
-- Called when a mouse is down on this component
--
UnitSelect = function(--[[ CtrlrComponent --]] comp, --[[ MouseEvent --]] event)
console("UnitSelect is fired")
local modName=L(comp:getOwner():getName())
console(modName)
local t={"ViButComA","ViButComB","ViButComC","ViButComD"}
for _,v in ipairs(t)do
panel:getModulatorByName(v):setModulatorValue(false, false, false, false) -- Set all other modulators to false
if v==ViButComA then
panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x0f, 0x40, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0xf7})) -- Press Button
panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x0f, 0x40, 0x00, 0x00, 0x01, 0x00, 0x02, 0x08, 0x00, 0xf7})) -- Release Button
console("Unit Button Pressed"..toString(v))
elseif v==ViButComB then
panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x0f, 0x40, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x01, 0xf7})) -- Press Button
panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x0f, 0x40, 0x00, 0x00, 0x01, 0x00, 0x02, 0x08, 0x01, 0xf7})) -- Release Button
console("Unit Button Pressed"..toString(v))
elseif v==ViButComC then
panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x0f, 0x40, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0xf7})) -- Press Button
panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x0f, 0x40, 0x00, 0x00, 0x01, 0x00, 0x02, 0x08, 0x02, 0xf7})) -- Release Button
console("Unit Button Pressed"..toString(v))
elseif v==ViButComD then
panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x0f, 0x40, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x03, 0xf7})) -- Press Button
panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x0f, 0x40, 0x00, 0x00, 0x01, 0x00, 0x02, 0x08, 0x03, 0xf7})) -- Release Button
console("Unit Button Pressed"..toString(v))
end
end
end
When I assign this script in the value change method it loops like crazy 🙂
Any clue about what could be possibly wrong?
I just need 1 shared script by 4 buttons with 4 different messages sent according to the button pressed and the radiobutton feature like in you demo. I am struggling to get this done.
Thanks a lot
Damien