Hi folks,
Currently the node-red-ui-contextmenu node can be displayed at a location that is specified:
- In the input message. For example when you click on an SVG shape, the node-red-contrib-ui-svg node sends the mouse-click coordinates in the output message, which can be used by the contextmenu node to show the menu nicely where the mouse has being clicked.
- In the config screen as a fixed location (x and y coordinates). For example when a dashboard button is being clicked, no coordinates will be available in the output message (so you need to used a fixed location).
@Paul-Reed has a problem with following flow:
[{"id":"b3e815dc.72d658","type":"ui_context_menu","z":"434e5cf6.9faa04","group":"b6d02685.824a58","order":17,"width":0,"height":0,"fontSize":16,"position":"fixed","outputField":"payload","xCoordinate":"125","yCoordinate":"118","menu":"fixed","menuItems":[{"id":"1","icon":"fa-arrow-right","label":"Realtime Power","topic":"dash","payload":"Realtime Power","payloadType":"str","visible":true,"enabled":true},{"id":"2","icon":"fa-heart","label":"Historical Energy","topic":"dash","payload":"Historical Energy","payloadType":"str","visible":true,"enabled":true}],"colors":"native","textColor":"#000000","backgroundColor":"#ffffff","borderColor":"#626262","intervalLength":"0","intervalUnit":"secs","startTimerAtOpen":true,"startTimerAtLeave":true,"stopTimerAtEnter":true,"name":"Menu","x":670,"y":280,"wires":[[]]},{"id":"721ee856.4907d8","type":"ui_button","z":"434e5cf6.9faa04","name":"","group":"b6d02685.824a58","order":2,"width":2,"height":1,"passthru":false,"label":"","tooltip":"","color":"","bgcolor":"#2A2A2A","icon":"fa-navicon fa-2x","payload":"","payloadType":"str","topic":"","x":510,"y":280,"wires":[["b3e815dc.72d658","e69ef5e8.3eda68"]]},{"id":"1440d7ac.5854a8","type":"ui_button","z":"434e5cf6.9faa04","name":"","group":"b6d02685.824a58","order":4,"width":2,"height":1,"passthru":false,"label":"My button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":520,"y":240,"wires":[[]]},{"id":"e69ef5e8.3eda68","type":"debug","z":"434e5cf6.9faa04","name":"Coordinate test","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":700,"y":340,"wires":[]},{"id":"b6d02685.824a58","type":"ui_group","z":0,"name":"flowtest","tab":"eb2b42a7.665b9","disp":true,"width":22,"collapse":false},{"id":"eb2b42a7.665b9","type":"ui_tab","z":0,"name":"Test","icon":"dashboard","order":6}]
When the button is clicked, a message (without coordinates) is being send to the contextmenu node. The contextmenu node shows the menu at a fixed location. But when the screen is resized, the menu is not drawn on top of the button anymore:
I 'think' are two valid solutions for this problem.
-
The contextmenu node currently displays the menu at clientx and clienty:
I could add an extra dropdown to the config screen (in case 'fixed coordinates' are selected) with options: "client coordinates" and "offset coordinates".
-
The dashboard button node could send the clicked coordinates (and perhaps if possible the bounding box as suggested in this discussion):
I will implement the first solution anyway, but the second solution would be much easier to use. But not sure if our friend @dceejay will agree with this proposal, since his impact analyses are always better than mine ...
Thanks for any suggestions!!
Bart