Hi Team,
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?
Below is the code snippet
@Output() rightClick: EventEmitter<{
x: number;
y: number;
isDiagramContext: boolean;
}> = new EventEmitter();
const $ = go.GraphObject.make;
const dia = $(go.Diagram, {
‘undoManager.isEnabled’: true,
initialAutoScale: go.Diagram.Uniform,
‘contextMenuTool.showContextMenu’: function (cm, obj) {
// const xPos = // How to get xPos ??
// const yPos = // How to get yPos ??
if (obj === null) {
// this.rightClick.emit({x: xPos, y: yPos, isDiagramContext: true });
} else {
// this.rightClick.emit({x: xPos, y: yPos, isDiagramContext: false });
// How to access this.rightClick ??
}
go.ContextMenuTool.prototype.showContextMenu.call(this, cm, obj);
}
This is the stackblitz app : Angular GoJs - StackBlitz