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
July 1, 2020 at 12:13 am
#118987
Alright, I fixed the issue with a statement based on the current value of the clicked modulator
It sends the message only if the button was not ON before clicking on it.
And it locks the position to ON if clicked a second time without sending the sysex message twice.
UnitSelect = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)
if source==4 then -- should stop this code running on start
local n=L(mod:getName())
local UnitModValue = panel:getModulatorByName(n):getModulatorValue()
local t={ViButComA=0,ViButComB=1,ViButComC=2,ViButComD=3}
console("Unit Selected Value : "..tostring(UnitModValue))
for k,v in pairs(t)do
if k==n and UnitModValue == 0 then
console("Unit Selected : "..tostring(k))
panel:getModulatorByName(k):setValue(1, true)
elseif k==n and UnitModValue == 1 then
panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x0f, 0x40, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, v, 0xf7})) -- press button
panel:sendMidiMessageNow(CtrlrMidiMessage({0xf0, 0x0f, 0x40, 0x00, 0x00, 0x01, 0x00, 0x02, 0x08, v, 0xf7})) -- release button
elseif k~=n then
panel:getModulatorByName(k):setValue(0, true)
end -- fi
end -- for
end -- source ==4 (user clicked on a button - not lua generated
end
Hope it will help people having trouble with radio buttons like me 😉