Cabbage Logo
Back to Cabbage Site

String-combobox created with cabbageCreate does not store value with cabbageChannelStateSave

Hi!
I noticed that when a combobox is created dynamically, Cabbage probably ignores its channelType=“String”.

Test csd:

<Cabbage>
form caption("Combo save state test") size(400, 300), guiMode("queue"), pluginId("def1")

combobox bounds(20, 10, 80, 28) channel("combo1")  items("Zero", "One" )  value("One") channelType("string") 

</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

schedule "Create",0, 0
instr Create   
    cabbageCreate "combobox", {{ bounds(20, 70, 80, 28) channel("combo2")  items("Two", "Three" )  value("Three") channelType("string") }} 
endin


schedule "Save", 5, 0
instr Save
    iRes cabbageChannelStateSave  sprintf("%s/test-channels.json", chnget:S("CSD_PATH"))
    print iRes
endin

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

Output of json:

        {
            "COMMON_DOCUMENTS_DIRECTORY": "/opt",
            "IS_A_STANDALONE": 1.0,
            "IS_BYPASSED": 1.0,
            "LINUX": 1.0,
            "Linux": 1.0,
            "PRESET_STATE": -1.0,
            "combo1": "One",
            "combo2": 1.0,
            "form": 0.0
        }

tarmo

Comboboxes have always been troublesome in Cabbage 2. I’ll take a look. In the meantime you can manually save the state of the combox using the other state save opcodes, i.e, cabbageSetStateValue.