Yesterday @bakman2 helped me no end with a button and getting the colours working as I wanted.
New day, new button.
This is what I have in the template
node:
<button ng-mousedown="send({payload: 'Down'})" ng-mouseup="send({payload: 'Up'})"> <i class="material-icons"> <span style="color:{{msg.colour}}"> volume_up </i> </button>
Alas this gives me a button with a white
background.
I would prefer it to be black. (Match the theme I am using.)
But even via the {msg}
would be ok. That allows me more options.
Though I think if you post the code with a fixed colour, I can nut it out.
Just for the fun of it, here is a bit of flow which flashes the button when pressed.
This is the flow.
[{"id":"bc5aa5c4.52161","type":"ui_template","z":"1781e581.31721a","group":"8418af9a.bbc66","name":"V Up","order":1,"width":2,"height":1,"format":"<button ng-mousedown=\"send({payload: 'Down'})\" ng-mouseup=\"send({payload: 'Up'})\"> <i class=\"material-icons\"> <span style=\"color:{{msg.colour}}\"> volume_up </i> </button>","storeOutMessages":true,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","x":3640,"y":680,"wires":[["6b7607e4.7d79c","15a715e3.e0c4fa","b51e2b02.46d418"]]},{"id":"6b7607e4.7d79c","type":"switch","z":"1781e581.31721a","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Down","vt":"str"},{"t":"eq","v":"Up","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":3860,"y":720,"wires":[[],["36fcedb1.36a5e2"]]},{"id":"b51e2b02.46d418","type":"trigger","z":"1781e581.31721a","op1":"Down","op2":"0","op1type":"str","op2type":"str","duration":"-140","extend":false,"units":"ms","reset":"Up","bytopic":"all","name":"Repeat","x":3870,"y":680,"wires":[["36fcedb1.36a5e2"]]},{"id":"36fcedb1.36a5e2","type":"function","z":"1781e581.31721a","name":"toggle","func":"var x = context.get(\"counter\") || 0;\nif (msg.payload == \"Up\")\n{\n context.set(\"counter\",0);\n msg.colour = \"black\";\n msg.payload = \"black\";\n return msg;\n}\n\nif (x === 0)\n{\n msg.colour = \"lime\";\n msg.payload = \"lime\";\n} else\nif (x === 1)\n{\n msg.colour = \"black\";\n msg.payload = \"black\";\n}\n\nx = (x + 1) % 2;\n\ncontext.set(\"counter\",x);\n\nreturn msg;","outputs":1,"noerr":0,"x":4020,"y":720,"wires":[["4732f533.e29164","bc5aa5c4.52161"]]},{"id":"4732f533.e29164","type":"debug","z":"1781e581.31721a","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":4160,"y":720,"wires":[]},{"id":"8418af9a.bbc66","type":"ui_group","z":"","name":"Group 4","tab":"b128eb09.9f681","order":5,"disp":true,"width":"4","collapse":false},{"id":"b128eb09.9f681","type":"ui_tab","z":"","name":"TV_Remote_control","icon":"dashboard","order":1,"disabled":false,"hidden":false}]