I couldn’t find that example I mentioned earlier, although I’m sure I implemented a radiogroup from scratch at one point. Here is some code that might help. I’m using radioGroup()
on each button, but the middle button has latched(0)
set. So it will actually trigger each time it’s pressed.
<Cabbage>
form caption("queue"), size(500, 240), guiMode("queue"), colour(20,20,20)
button bounds(60, 48, 80, 40) channel("button1"), text("Clear"), colour:1(0, 200, 0), value(1), radioGroup(1)
button bounds(150, 48, 80, 40) channel("button2"), items("Record"), radioGroup(1), latched(0)
button bounds(240, 48, 80, 40) channel("button3"), text("Play"), colour:1(0, 200, 0), radioGroup(1)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-dm0 -n
</CsOptions>
<CsInstruments>
; sr set by host
ksmps = 16
nchnls = 2
0dbfs = 1
instr 1
k1, kTrig1 cabbageGetValue "button1"
k2, kTrig2 cabbageGetValue "button2"
k3, kTrig3 cabbageGetValue "button3"
kClicked init 0
if kTrig3+kTrig1 > 0 then
cabbageSet 1, "button2", "colour:0(0, 0, 0)"
kClicked = 0
endif
if changed:k(k2) == 1 then
if kClicked == 1 then
cabbageSet 1, "button2", "colour:0(0, 200, 0)"
elseif kClicked == 3 then
cabbageSetValue "button3", 1, 1
cabbageSet 1, "button2", "colour:0(0, 0, 0)"
kClicked = -1
endif
kClicked += 1
endif
endin
</CsInstruments>
<CsScore>
i 1 0 z
</CsScore>
</CsoundSynthesizer>