admin管理员组

文章数量:1279008

I'm trying to make an event for rightclicking an element in jointjs, however the event does not fire at all for right click only left click and middle click work. How to make it work for right click? Why doesn't it work?

this.paper.on('element:pointerdown', (elementView: any, event: MouseEvent) => {
  console.log("1");
  if (event.button === 2) {
    console.log("2");
    event.preventDefault();
    this.startEdgeCreation(elementView.model, event);
  }
});

I'm trying to make an event for rightclicking an element in jointjs, however the event does not fire at all for right click only left click and middle click work. How to make it work for right click? Why doesn't it work?

this.paper.on('element:pointerdown', (elementView: any, event: MouseEvent) => {
  console.log("1");
  if (event.button === 2) {
    console.log("2");
    event.preventDefault();
    this.startEdgeCreation(elementView.model, event);
  }
});
Share Improve this question asked Feb 24 at 4:35 MiccaMicca 372 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

You should use the element:contextmenu event instead: https://docs.jointjs/api/dia/Paper/#contextmenu

So, in your case:

this.paper.on('element:contextmenu', (elementView: any, event: MouseEvent) => {
    console.log("2");
    event.preventDefault();
    this.startEdgeCreation(elementView.model, event);
});

本文标签: