Cabbage Logo
Back to Cabbage Site

Widget Placement and MouseOver control

I am designing my gui with a bunch of ‘rslider’ widgets very close together. When i run the gui and the mouse is over these components, because the bounds for one widget overlaps another, the mouse will actually be over one component, but a mouseclick will control the neighboring widget.

In this example, when the mouse is over the righthand side of the “Oct” widget and the button is pressed, the “Int” widget will activate. widgettest.csd (920 Bytes)

Is there a way to set the mouse over box on a widget?

If it matters, I am running Mac OS 10.13.6…

The problem here is that the slider is being resized to accommodate the text and number boxes. You can achieve this by not setting and text or number box, and using labels for these elements instead. For example, these two slider can be placed right beside each other with no overlap:

rslider bounds(140, 32, 36, 36) channel("rslider10000") range(0, 1, 0, 1, 0.001)
rslider bounds(176, 32, 36, 36) channel("rslider20000") range(0, 1, 0, 1, 0.001)

OK, makes sense. I took out the text and value boxes without changing the size of the widget, then ran it. The bounds were in the very positions as before, overlapping the next widget. Good thing I asked before starting the cabbageCreate stuff.

Also, the reason I included the text box is to allow entering in numbers. Is it possible duplicate that?

I was testing to see if I could just attach an ‘nslider’ with a different channel name, but in order to have the ‘nslider’ set the value of the ‘rslider’, which inturn will set the ‘nslider’. This creates an infinite loop. Is there a way to set the value of a widget that won’t propagate the event? PureData allows you to ‘set’ the value that won’t pass on the event.

<Cabbage>
form caption("Untitled") size(400, 300), guiMode("queue"), pluginId("def1")

rslider bounds(140, 32, 36, 36) channel("vox1octave") range(-4, 4, 0, 1, 1)
rslider bounds(176, 32, 36, 36) channel("vox1interval") range(-12, 12, 0, 1, 1)

nslider bounds(136, 64, 44, 20) channel("vox1octaveN") range(-4, 4, 0, 1, 1) colour(0, 0, 0, 0)

keyboard bounds(8, 158, 381, 95)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

;instrument will be triggered by keyboard widget
instr 1
    kVox1Octave, kVox1OctaveTrig cabbageGetValue "vox1octave"
    kVox1OctaveN, kVox1OctaveNTrig cabbageGetValue "vox1octaveN"
    
    if kVox1OctaveTrig == 1 then
        printks "getting kVox1Octave (%d)\n", 0, kVox1Octave
        cabbageSetValue "vox1octaveN", kVox1Octave
    endif
    if kVox1OctaveNTrig == 1 then
        printks "getting kVox1OctaveN (%d)\n", 0, kVox1OctaveN
        ; with the following, an infinite loop would occur
        ; cabbageSetValue "vox1octave", kVox1OctaveN
    endif
endin

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

Maybe something like this, it’s a solution that addresses a specific problem. All this would do is set the value of the widget, but won’t trigger an event.

cabbageSet kVox1OctaveNTrig, "vox1octave", "value", kVox1OctaveN

OK, trying a different tactic. Instead of using the ‘rslider’ as the main component, I put the ‘nslider’ on top of it, and it now controls the ‘rslider’. The ‘rslider’ is now just cosmetic.

1 Like