Open contextmenu programmatically

452 views Asked by At

I have a svg element on top of the viewer canvas created with snap.svg, so I can draw nametags for elements on this svg layer. After I create the svg layer the viewer reacts to left clicks normally, but doesn't open the context menu anymore. How to open the context menu programmatically? I can catch the click event with jQuery and get the x and y location.

$("#svg-canvas").contextmenu(function (e) {
  console.log('x: ' + e.screenX + ' y: ' + e.screenY);
});

I tried also changing the z-index of .menu and the svg layer, but if the svg layer is on top and shows the svg elements, it does not open the context menu with right click.

1

There are 1 answers

0
Joni Turunen On BEST ANSWER

I looked at the Viewer 2.11 source code and this seems to work.

viewer.contextMenu.show(event);