Cabbage Logo
Back to Cabbage Site

Dynamic population of combobox

Hi Rory,

I am working on a plugin With Cabbage 2 where it would be really necessary to filter items out of a choice of over 500 elemnts for combobox. (so a Textedit for input, “Search” button that sets the comobobox choices.
If it is a string value comobox, I found a post Changing combobox and listbox items that it used to be possible in the older guiMode. What about now? I could not find a way with cabbageSet for that.

What do you say?

Thanks!
tarmo

Hi @tarmoj, I hope all is well. I apologise for taking so long to reply. This code works for me:

<Cabbage>
form caption("Untitled") size(400, 300), guiMode("queue"), pluginId("def1")
combobox bounds(148, 41, 80, 20) channel("combo1"), channelType("string"), items("One", "Two", "Three")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget
instr 1
cabbageSet "combo1", "text(\"1\", \"2\", \"3\", \"4\", \"5\")"
endin

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
i1 1 1
</CsScore>
</CsoundSynthesizer>

Thanks!

Yes! Now I get it, that helps!

tarmo

1 Like

Hi!

I am getting back to this as I noticed a weird behavior - everything worked perfectly on Cabbage 2.9.0 but when I tried with 2.10.4 - it refills the comobobox but as soon I select something, it freezes as if in indefinite loop.
The freeze happens when there is more new elements than defined originally, as in this example.
When there is the same number or less, like

cabbageSet “combo1”, “text(“1”, “2”, “3”)”

It does not crash, the dropdown opens, but I cannot select any. Or in fact, it always selects the last element.

Again - on Cabbage 2.9.0 it works as expected. I am on opeSuse and had the same behavior on Windows 11, Cabbage 2.10.

Can you recreate? What can be the reason?

tarmo

Let me take a look and see :+1: I’m still in holidays so it will be a few days :grin: