you are using invalid double quotes characters (maybe referred to as “smart quotes”, never ever use these in programmation languages, stick to the basic ")
your formula (the #{} block) doesn’t output anything because all lines end with semi-colons
my_fcolors(couleur) is not valid, you should write my_fcolors[couleur] using brackets instead of parenthesis
The above codes uses arrays to store the colors, you can only access array items using integers. If you want to use arbitrary values (such as “01”), you’ll need to use an object instead.
Short generic example:
var colors = {
"aa" : "red",
"bb" : "blue"
}
var x = "aa"
console.log(colors[x]) // red
In the property values, you should have some Key-value pairs. value.on selects a tag “value” with class “on”. if you have just one switch, i am not sure if there is a class “on”, try more…
@Greenman the code was supposed to work with a switch widget. A button widget does not contain any html value element that would be affected by the css.
Ok my bad.
But except the fact that i’m dumb not to have see it was a switch, it would be nice if people publish a little json session file to allow others to learn how to use o-s-c.
O-s-c is a free software no ? So the philosophy is to share to learn together. Bref…
I’m not saying you’re dumb and I’m sorry if it sounded like it.
However I do believe the explanations above are far from cryptic and I’m not convinced providing a session file with every answer I give is the best solution.
Within O-S-C, css is a way to hack things around if you take the time to learn how it works, along with some general html logic which it’s tied to. I can’t possibly support every use case because there are just so many of them, and I find your answer a bit harsh considering the fact I actually try to give examples most of the time.
of course you are not included into my 'people' (évidemment).
Evidemment je ne parlais pas de toi ! vu le boulot et les réponses que tu fournis, je ne me permettrai pas. Je dis simplement qu'on aurait tous à y gagner si, sur ce forum, une fois la solution trouvée, les intervenants concluaient par une explication, si possible, et un fichier json de leur session. C'est en voyant du code propre à o-s-c qu'on apprendra à s'en servir. Même si ce sont des cas particuliers, des installations propres à l'utilisateur, c'est toujours intéressant. voilà voilà et t'inquiète je ne l'ai pas mal pris. J'ai passé l'âge -
ps : ah oui lorsqu'on arrive sur le site du projet aucun lien visible vers ce forum
A little bug to consider. If i put colorFill to false (is it the good way ?) instead of using auto not to fill the button (it works) then finally, change my mind and click on the color selector square, choose a color, the color is not applied. switch-values-colors.json (3.8 KB)
false is not a valid color (there's an error in the console when trying to submit this value). What happens next is that the color picker starts with alpha of 0, hence your change not being visible.
ps : ah oui lorsqu’on arrive sur le site du projet aucun lien visible vers ce forum