I’ve just discovered the switcher widget (not to be confused with the switch).
Previously I’ve been trying to display the value of several modules on a switch’s buttons, but if I am right, this would rather be a job for switcher. However, I am not sure about two things:
1.In the linkedWidgets
property, should the names of the widgets be between quotes like this?
{
“mebiii_selector”,
“group1a_selector”,
}
2. How should I encode the values
property to display the values of the linked widgets rather than "Value 1, “Value 2”, etc?
This is kind of what I mean, and I’m right with you. If there were short examples of how to use each widget, geared towards people who are not necessarily coders, I think this would be really helpful. Lots of work though most probably…
1.In the linkedWidgets
property, should the names of the widgets be between quotes like this?
linkedWidgets
is either a string (a single widget id) or an array of id strings (with brackets instead of braces) [edit: never use smart quotes “”
] :
[
"mebiii_selector",
"group1a_selector",
]
2.How should I encode the values property to display the values of the linked widgets rather than "Value 1, “Value 2”, etc?
This is really not what the switcher widget is about actually, the values
property defines a set of bank that store the linked widgets value changes. When a linked widget updates, the currently selected bank stores the new value, and when a different bank is selected, it sets the linked widgets to the value stored if any.
I see… …not exactly what I thought. So I’ll ask another question: is it possible to change the labels of a switch dynamically according to values of other widgets?
You can use the advanced property syntaxes in the values property:
{
"@{widget_id1}": 1,
"@{widget_id2}": 2
}
Edit: that’s probably a bad idea though, because the widget will be recreated each time the value changes, you might wanna display these values in input or text widgets (one per widget).
Yes, I thought about that but it's strange to use two widgets on the screen where one could do both jobs. Maybe I'll put a transparent switch on a series of text widgets. Is it possible not to display any label at all on a switch's buttons?
Is it possible not to display any label at all on a switch’s buttons?
Some css magic should do the trick!
opacity could be my friend.
Just for the record: it seems that if one wants to make a whole widget transparent, only :host{}
works (not .widgetname{}
).
The state widget is in git and will be included in next release
1 Like