Momentary toggle button

Hi,
i found this flow here:
https://flows.nodered.org/flow/badf32e71913b09a2d8e2488a1b101a5
Great, a mouse-down and a mouse-up output, perfect for the needs of buttons to control a PTZ-Camera.

Works great with one button, but fails if i use 6 buttons (up, down, left, right, zoom+ and zoom-). In the case of 6 buttons, i see always more than one button triggert.

Wat is necessary to make these buttons work independent?

Thats because they reference the same class "momentary ". try giving all <div>'s a different class, and changing the reference to momentary in the function to match the class.

Or you could just add all the buttons in one template, sending a payload "true/false" and a topic "up/down/left/right/zoom in/out".
Than you can route with a switch on the topic.

[{"id":"4a193389.e055ac","type":"ui_template","z":"bf9e1e33.030598","group":"4ba5d415.d302ec","name":"Toggle Button","order":1,"width":"0","height":"0","format":"<div>\n   <md-button ng-mousedown=\"send({payload: true, topic: 'up'})\" ng-mouseup=\"send({payload: false, topic: 'up'})\" style=\"width:100%; height:48px; margin: 0px\">up</md-button>\n   <md-button ng-mousedown=\"send({payload: true, topic: 'down'})\" ng-mouseup=\"send({payload: false, topic: 'down'})\" style=\"width:100%; height:48px; margin: 0px\">down</md-button>\n</div>\n\n","storeOutMessages":false,"fwdInMessages":false,"resendOnRefresh":false,"templateScope":"local","className":"","x":250,"y":80,"wires":[["fa34fe67.be89c"]]},{"id":"fa34fe67.be89c","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":430,"y":80,"wires":[]},{"id":"4ba5d415.d302ec","type":"ui_group","name":"Control","tab":"47f0556b.db072c","order":1,"disp":true,"width":"6","collapse":false},{"id":"47f0556b.db072c","type":"ui_tab","name":"ICM","icon":"dashboard"}]
2 Likes

Thank you, works perfect!

Edit: i gave the divs a different name and matched it in the scope as well.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.