Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jointjs - element:pointerdown for rightclick doesnt fire, only left click and middle button click

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);
  }
});
like image 319
Micca Avatar asked Dec 17 '25 21:12

Micca


1 Answers

You should use the element:contextmenu event instead: https://docs.jointjs.com/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);
});
like image 88
jaytibann Avatar answered Dec 19 '25 11:12

jaytibann



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!