Reply To: Radio button in a modulator group needs a default setting

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

#118987
damien
Participant
  • Topics: 15
  • Replies: 62
  • Total: 77

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 😉

  • This reply was modified 6 months, 3 weeks ago by damien.
  • This reply was modified 6 months, 3 weeks ago by damien. Reason: addons
Do NOT follow this link or you will be banned from the site!