I am trying to implement a custom context menu passing the x,y coordinates from GoJs to the consumer component.
How to get the x & y coordinates on the context menu open and call an outside method using this?
I was able to get the instance of this by trying something like you mentioned. Thanks for the tip.
But, the coordinates from mouseDownPoint seems to be different, I even get negative values as coordinates. It’s also not relative to the gojs diagram container div.
I need the x & y offset coordinates from the window.
As the documentation states, ContextMenuTool.mouseDownPoint is in document coordinates: ContextMenuTool | GoJS API
You can call Diagram.transformDocToViewDiagram | GoJS API to convert that to viewport coordinates – i.e. relative to the top-left corner of the Diagram’s HTMLDivElement.