Change variable at root level

Yet another question :slight_smile:

How do I change a variable defined at root level, from different widgets?

Cheers
Søren

You mean the variable property ? You could make it depend on another widget’s value (say, an input):
{"x": "@{input_id}"}
and change that input’s value to affect the variable. The variable can be retreived with @{root.variables.x} except for the root’s direct children (main tabs) which must use @{parent.variables.x} instead (as stated in the docs).

Thankyou, I found this answer also in another thread.

However, what I’m trying is a bit more complex. I have a set of individual buttons, that addresses @{nr} I have a text widget with two different values, as you showed me earlier

@{nr}
@{name_@{nr}}

But if I use linkId (set to nr), I only get that one value in the text display. So I’m trying to make the buttons change a variable value(property?) at root level, and then let the text widget reference that.

Does that make sense?

I’m not entirely sure to get it, but it sounds a bit over-complicated. I think you should be able to solve this with a script widget, linked to the buttons that trigger the text update, and let that script widget define the text’s value. Something like:

JS{{
// "script" property
// executed whenever the script widget receives a value

var val_nr = get("nr")
var val_x = get("name_" + val_nr)

set("text_id", val_nr + "\n" + val_x)

}} 

Of course! I didn’t think to add the newline in there…doh! Again - I’m in your debt :slight_smile: