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
DnaldDoog,
Don’t worry my friend. I know your post vanished in the abyss but I received it via mail. I’ll check your method tomorrow. My main concern is that “on mouse down” feature doesn’t work properly with images as button, it’s something wrong with the Ctrlr app itself.
I’ll check and try what you posted.
thanks a lot!
dnaldoog wrote:
Well it becomes difficult when you need to use these buttons as toggle buttons sending MIDI 0/1 or 0/127.
Here is a more developed version:
First I have an some initialising code in a function that runs when the panel loads.
—
— Called when the panel has finished loading
—
— @type the type of instance beeing started, types available in the CtrlrPanel
— class as enum
—
— InstanceSingle
— InstanceMulti
— InstanceSingleRestriced
— InstanceSingleEngine
— InstanceMultiEngine
— InstanceSingleRestrictedEngine
—
init = function(–[[ CtrlrInstance –]] type)
dontBlock=false
panel:getModulatorByName(“ButtonA”):setValue(1,false)
panel:getModulatorByName(“ButtonB”):setValue(0,false)
panel:getModulatorByName(“ButtonC”):setValue(0,false)
myGlobal=”ButtonA”
globalValue=127
endthen a common mouse down function attached to each button:
—
— Called when a mouse is down on this component
—myRadio = function(–[[ CtrlrComponent –]] comp, –[[ MouseEvent –]] event)
local modName=L(comp:getOwner():getName())
dontBlock=true
if dontBlock then
local t={ButtonA=75,ButtonB=76,ButtonC=77}
for k,v in pairs(t)do
panel:getModulatorByName(k):getComponent():setValue(0,false)–set all other modulators to false
if k==modName then
if myGlobal==tostring(k) and globalValue==127 then
globalValue=0
else
globalValue=127
end
— do something
panel:sendMidiMessageNow(CtrlrMidiMessage(string.format(“B6 %.2x %.2x”,v,globalValue)))
panel:getLabel(“debug”):setText(k..”\nsending “..string.format(“%.2X”,globalValue))
myGlobal=tostring(k)end
end
end — dontBlock
end –fNote the change in the t{} table to a hash table:
Regards,
JG