Cabbage Logo
Back to Cabbage Site

Getting Values From Combobox

Hi, I’m working on my graduation project and I want to learn about how I can read a value from the combobox selection. I kind of learned my way around the GUI editor and managed to create a combobox with the list of items i want but I have no idea how I can access those from inside the code. What should I do?

I see two options for that:

1

You can get the current index of the item selected and then get the value based on the array you defined in the code.

2

You can use “channelType(“string”)” to get the string instead of the index.

Cf: Reading combobox strings

1 Like

Thank you. I copied this part from the link,

 if chnget:k("waveshape") == 1 then
	a1 oscili .75, p4

Would this work by itself? After I match the channel name of the combobox and the “waveshape” part of course.

If I understand well this block is executed everytime “waveshape” changes, so you don’t actually get a value from it.

Here is a minimal example to show how I would have done it (however there are probably better options)

comboboxtext.csd

1 Like

I’m also new to coding in general so I’ll go and make some mistakes now. Thanks again.

In fact, your understanding here is correct, The a1 oscili... code will be read for as long as waveshape == 1. If you post a more complete example w can take a look over it for you.

My bad I misunderstood the chnget:k syntax, I thought it would return 1 when the channel “waveshape” changes but I was wrong!

You probably got it mixed up with a changed opcode which is used all over the examples too.

1 Like