Cabbage Logo
Back to Cabbage Site

Changing combobox and listbox items

Hi
I’m trying to change the contents of a combobox and a listbox after creation but can’t. In the example below the colour changes but the items do not. Am I going about this in the correct way? I’m running 2.5.0 x64 on Windows.
cabbage-combo.csd (657 Bytes)

<Cabbage>
 form caption("Test") size(400, 300), pluginid("def1")
combobox bounds(0, 0, 300, 50) items("Nothing", "Here") identchannel("combo_ident") value(1) channel("combo")
listbox bounds(0, 100, 300, 50) items("Nothing", "Here") identchannel("lbox_ident") value(1) channel("lbox")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1
    chnset {{colour(255, 0, 0), items("Some", "Items", "Here")}}, "combo_ident"
    chnset {{colour(255, 0, 0), items("Some", "Items", "Here")}}, "lbox_ident"
endin

</CsInstruments>
<CsScore>
f0 z
i1 0 1
</CsScore>
</CsoundSynthesizer>

Hi @richardk. This is not possible with a combobox, much in the same way it is not possible to dynamically change the range of a slider. The reason is that hosts use the number of items in a combobox, and the range of sliders to set parameter mapping when a plugin first loads. Once these parameters are set, they cannot be changed. Doing so would cause some very odd behaviour in the host.

Comboboxes with channeltype() set to string don’t work with host automation, so I guess I could allow those to by dynamically updated. Would that work?

Thanks @rorywalsh , I thought this could possibly be the case.
Allowing dynamic update to string channeltype() widgets would work for me - if that’s something you could fit in sometime in the future, then that’d be great, thank you!

Should be possible. Leave it with me. I probably won’t have time till early next week. Weekends are family time :wink:

I managed to squeeze this in before clocking off :wink: A new build is under way. You can grab it from here when its done. Here is the test .csd I was using, based on your earlier one.

<Cabbage>
 form caption("Test") size(400, 300), pluginid("def1")
combobox bounds(0, 0, 300, 50) items("Nothing", "Here") identchannel("combo_ident") channeltype("string"), value(1) channel("combo")
listbox bounds(0, 100, 300, 50) items("Nothing", "Here") identchannel("lbox_ident") channeltype("string"), value(1) channel("lbox")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
</CsOptions>
<CsInstruments>
ksmps = 32
nchnls = 2
0dbfs = 1

instr 1
    chnset {{colour(255, 0, 0), items("Some", "Items", "Here"), value("Here")}}, "combo_ident"
    chnset {{colour(255, 0, 0), items("Some", "Items", "Here"), value("Some")}}, "lbox_ident"
endin

</CsInstruments>
<CsScore>
f0 z
i1 0 1
</CsScore>
</CsoundSynthesizer>
1 Like

Oh, that’s fantastic, thanks!