Switch changes dropdown's values -> need to call back last value

Hi there !

I use a switch to change a dropdown's values, to select Quantize / Quantize-Insertion values.
Q

Each time i switch from "Q" to "Q Insertion", it sets the dropdown to 0 (or undefined).
I need the values to be memorized and called back.

To do so, i tried this :

  • created two variables : mémo_Q and mémo_Q_Insert

  • script in dropdown's inspector :

if(@{switch_Q} == 1) set("mémo_Q",value)

else if(@{switch_Q} == 2) set("mémo_Q_Insert",value)
  • script in switch's inspector :
if(value == 1) 
{
set("dropdown_values",
		{"1/1":80,"1/2":81,"1/4":82,"1/8":83,
			"1/16":84,"1/32":85,"1/64":86,"1/128":87});
set("color",'blue');
set("dropdown_Q",@{mémo_Q});
}

else if(value == 2) 
{
set("dropdown_values",
	{"1/1":70,"1/2":71,"1/4":72,"1/8":73,
		"1/16":74,"1/32":75,"1/64":76,"1/128":77});
set("color",'yellow');
set("dropdown_Q",@{mémo_Q_Insert});
}

Now, as you can imagine... that doesn't really work... So how to do that ?

Thank you

Don't use @{} in scripts, use get() instead. Besides this it doesn''t look wrong. If you upload your session file I may be able to understand what doesn't work.

An alternative solution that you might find easier to work with: create 2 dropdowns with the different sets of values you need, get rid of all the above scripts and simply make the visibility of the dropdowns depend on the state of the switch:

  • dropdown1.visible:
#{@{switch} == 1}
  • dropdown2.visible:
#{@{switch} == 2}

Merci, voilà le petit chose.

Q.json (8.9 KB)

In the console (ctrl+K) you can see an error when clicking on the switch, there are some quotes missing in the switch's script (in get() calls). If you remove the remaining @{} in the dropdown's script, it will work.

Done. Thanks a lot !