Updating EZSlider variable by EZPopMenu item

Hello everyone,

I am trying to link the EZPopMenu value with a variable length slider.
Each item from the PopMenu points to a different buffer length which I assign it to a global variable ~lastStartPosition.
Then I would like to set the “maxval” from the EZSlider with this value.

The issue is that everytime I select the item in the EZPopMenu, I have to re-evaluate the ~tremDurSlider object to assign the new value. Otherwise, it keeps the early one.

I believe that it is a kind of order of execuction issue but I am not able to set this right.

Anyone, please, could help me ?
any tips?

Thank you guys for everything!

~btnSelectLoop = EZPopUpMenu.new(w.view, Rect.new(1250,40,110,30),
	"",
	[
		\Select_Patch ->{|a| ~testN = a.value-1; ("this is an empty Buffer").postln},
		\Patch_1 ->{|a| ~testN = a.value-1; ("this is Buffer " ++ a.value).postln},
        \Patch_2 ->{|a| ~testN = a.value-1; ("this is Buffer " ++ a.value).postln},
        \Patch_3 ->{|a| ~testN = a.value-1; ("this is Buffer " ++ a.value).postln},
		\Patch_4 ->{|a| ~testN = a.value-1; ("this is Buffer " ++ a.value).postln},
        \Patch_5 ->{|a| ~testN = a.value-1; ("this is Buffer " ++ a.value).postln},
        \Patch_6 ->{|a| ~testN = a.value-1; ("this is Buffer " ++ a.value).postln},
		\Patch_7 ->{|a| ~testN = a.value-1; ("this is Buffer " ++ a.value).postln},
        \Patch_8 ->{|a| ~testN = a.value-1; ("this is Buffer " ++ a.value).postln},
        \Patch_9 ->{|a| ~testN = a.value-1; ("this is Buffer " ++ a.value).postln},
		\Patch_10 ->{|a| ~testN = a.value-1; ("this is Buffer " ++ a.value).postln},
	],
	globalAction: {
		y.free;
		(~looper[~testN].set(\trigSend, 1)).value;
		y = OSCFunc({ arg msg, time; // receive trigger
			~lastStartPosition = (msg[3]/48000).postln;
		},'/the_answer', s.addr);
	},
	initVal: 0,
    initAction: true;
);

~tremDurSlider = EZSlider(w.view, Rect.new(950,120,285,25), nil,  ControlSpec(0.01, ~lastStartPosition, \lin, 0.01), initVal: 0.0, unitWidth:0, numberWidth:60,layout:\horz);

Best I can find:

x = EZSlider(nil, Rect(800, 200, 350, 50), "test", [0, 1], initVal: 0.5);

// later
(
var topValue = 5;  // or other number
x.set(x.label, spec: [0, topValue], initVal: x.value);
)

It’s not wonderful that the label and value must be repeated, but this seems to work anyway.

hjh

1 Like

Hi @jamshark70

Thank you so much! It worked and I did not realise that “.set” could be used that way. I was believing that it could be used mainly with SynthDef or something similar.

Thank you so much!
Best!