Cabbage Logo
Back to Cabbage Site

Technical question about chnget and changed

Hello,
In almost all examples, there is always the equivalent of
ktrig changed:k(chnget:k(“widgetname” ))
If ktrig==1 then…

Could you tell me why we check if it is changed instead of getting the value directly?.. As it seems to me that the value is captured anyway for comparing with previous value… Is this to save some CPU?
And if necessary, could this be implemented at once? i. e. as a macro?

First we want to know if the value has changed, if so, then we check for the value. In an event driven system we need to know when an event is taking place, and then we need to deal with it. I usually use this if I’m triggering other instruments or working with buttons.

and does it work for combobox too? because i want to show a different graphic depending on the item selected from the combobox

Sure. It works with any widget that can send a value to Csound. :+1: