Cabbage Logo
Back to Cabbage Site

Attempt one for linking widgets

I’m trying to find a way of having a bunch of rslider widgets interact with a companion nslider. I got it to work. But then in my revision to handle multiple rsliders using “cabbageChanged”, with a set of arrays with the channel names for each of the widgets, I’m getting some weird things that don’t make sense to me…

Basically, in the three rsliders on the right, they are grouped together and controlled by the instr “watcher2”. When I make any kind of adjustment using the rslider, everything seems to work fine. But when I make any kind of adjustment to the nslider, only the last rslider to be touched with see any kind of change. Hopefully the video will show what I mean.

WidgetInteraction.csd (2.2 KB)

It always happens like this… I found the problem!!!

This seems likely to fail because when you change the value of one widget according to another, it will in turn trigger the changed for that widget you just updated and the else will fail. This one works better, but still not 100%:

instr watcher2
    kKnobIndex, kKnobIndexTrig cabbageChanged gSKnobChannels
    kBoxIndex, kBoxIndexTrig cabbageChanged gSBoxChannels        

    if kKnobIndexTrig == 1 then
        kVal cabbageGetValue gSKnobChannels[kKnobIndex]
        cabbageSetValue gSBoxChannels[kKnobIndex], kVal
    endif
    if kBoxIndexTrig == 1 then
        kVal cabbageGetValue gSBoxChannels[kKnobIndex]
        cabbageSetValue gSKnobChannels[kKnobIndex], kVal
    endif
endin

But maybe you can work out a solution now we know the problem…

Try this one, there were some index issues in your code…

instr watcher2
    kKnobIndex, kKnobIndexTrig cabbageChanged gSKnobChannels
    kBoxIndex, kBoxIndexTrig cabbageChanged gSBoxChannels

    if kKnobIndexTrig == 1 then
        kVal cabbageGetValue gSKnobChannels[kKnobIndex]
        cabbageSetValue gSBoxChannels[kKnobIndex], kVal
    endif
    
    if kBoxIndexTrig == 1 then
        kVal cabbageGetValue gSBoxChannels[kBoxIndex]
        cabbageSetValue gSKnobChannels[kBoxIndex], kVal
    endif
endin

Yeah… found that right after I posted! But I’m glad your keen eyes were so attentive!