I’m working with the optionButton, and seem to be struggling to extract the current string-value of the channel with cabbageGetValue. Is this possible? Found nothing about it in the docs:
Currently the only workaround is to get th index and then looks up the values yourself. For example:
<Cabbage>
[
{ "type": "form", "caption": "Untitled", "size": {"height": 300, "width": 600}, "pluginId": "def1" },
{
"type" : "optionButton",
"bounds" : {"left": 45, "top": 47},
"channels": [ {"id": "optionButton2", "range": {}} ]
}
]
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
nchnls = 2
0dbfs = 1
instr 1
items:S = [“Item1”, “Item2”, “Item3”]
optionButton:k, optionButtonTrig:k = cabbageGetValue(“optionButton2”)
printf(“Selected item: %s”, optionButtonTrig, items[optionButton])
endin
</CsInstruments>
<CsScore>
i1 0 z
</CsScore>
</CsoundSynthesizer>
I am going to add an array version of cabbageGet to get the items array. That will make things a little simpler. I can also add a `currentText` property. I can do that now and trigger a new build.
I just triggered a new build wher we can now do this:
instr 1
items:S[] = cabbageGet("optionButton2", "items")
optionButton:k, optionButtonTrig:k = cabbageGetValue("optionButton2")
printf("Selected item: %s", optionButtonTrig, items[optionButton])
endin
This update features quite a bit of work done in the dev branch over the last month. Let me know if you have any problems.
1 Like

