Cabbage Logo
Back to Cabbage Site

Combobox vs Listbox Dynamicism

Just to get some official clarity here. Please let me know if I understand correctly:

• Can be dynamically populated
• Can be dynamically selected

• Can be dynamically populated
• Cannot ever be dynamically selected - just curious why it can work with snapshots but not with a Csound call?
• Can be initialized with a value or string in Cabbage section or cabbageCreate

In a specific case where you want to populate a combobox with a system directory and select an initial value for it, you would ideally check for OS in Csound (to populate the combobox with the correct path) and then use cabbageCreate to populate the combobox and set the initial value. You cannot set a combobox value with cabbageSet or cabbageSetValue - only with cabbageCreate.

It can, but not if the combobox is showing presets. Here is an example:

No, this can also be done:

So the only limitation is when you are dealing with comboboxes that list native Cabbage presets. These combo boxes are off limits.

Thanks for clarifying. I’m not sure why I’ve been having so much trouble with this but I’m glad to know they don’t have those limitations. For some reason I cannot seem to get any of my comboboxes to dynamically select a string… Does it always need to be k-rate?


cabbageSet "combobox4", sprintf("populate(\"*.orc\", \"%s\"), value(\"Empty.orc\")", gSEffectDir)

or k-rate

cabbageSet metro(2), "combobox4", sprintfk("populate(\"*.orc\", \"%s\"), value(\"Empty.orc\")", gSEffectDir)

They populate but do not select.

I should mention that this does work for me if I simply change the combobox referenced to a listbox - hence the conclusion I drew on the OP. See here

Comboboxtest.csd (741 Bytes)

I think it’s safer to set the value after calling populate(). Try this one. I can open a directory and then set a file from that dir as the selected item. Note I have to append the full path to the file first. Although the listbox displays the file name only, it keeps the full file path internally when you use the populate() identifier.

testCabbageSet.csd (981 Bytes)

Yep - that works - cool! BUT - and this is a problem I’ve run into all week - the value for dynamically set widgets don’t send the value back to Csound. This is for all widgets. They display the value but do not actually change the value.

See the simple example attached, The gain slider although dynamically set, does not affect the signal until the widget is moved…
testCabbageSet (1).csd (707 Bytes)

This works fine until you comment out the call to cabbageSetValue and replace it with the cabbageSet. I gotta ask, why not just use the cabbageSetValue? Also, if in the example I posted, the item that is dynamically chosen is sent to Csound. Add a printf as I’ve done here and you will see get updates when the second cabbageSet is called.

instr 1
    SFileButton, kTrigFile cabbageGetValue "filebutton1"
    cabbageSet kTrigFile, "EffectList1", sprintfk("populate(\"*.csd\", \"%s\")", SFileButton)
    cabbageSet kTrigFile, "EffectList1", sprintfk("value(\"%s/%s\")", SFileButton, "AM.csd")
    printf chnget:S("EffectList1"), metro(1)

I’m still trying to add support for value() to the Cabbage set opcodes, it’s always going to be better to use the cabbageSetValue. Tomorrow I will add support to cabbageSetValue for string arguments.

Yes, I was using cabbageSetValue but it was updating at k-rate - so I couldn’t change the widget. Will see if that works now in the latest beta

Still the same behavior on my end

I must be doing something wrong or not understanding something clearly here…

Also, if in the example I posted, the item that is dynamically chosen is sent to Csound. Add a printf as I’ve done here and you will see get updates when the second cabbageSet is called.

Yes, you are right.

I think I need to add an i-rate cabbageSetValue Tbh, I never gave it much thought as one can just set the default value when declaring the widget. But I can see now many use cases for being able to set these things when an instrument starts.

I’ve no added an i-time version of cabbageSetValue. I’ve also added support for widgets whose values are strings. I’ll post about those in the relevant thread. There are some awkward caveats due to how Csound handles strings…

I was about to ask how to select a value from a listbox of strings.
I’m using chnset at the moment but will look in these updates. Thank you

Thanks so much. Will test it out later this week when I’m back in.