Shubham Shinde
Shubham Shinde

Reputation: 1

How to ignore right click on Easel JS

I am working on Easel JS and came across one issue. If I am adding Events to one easelJs element then how can I ignore the right-click and only listen to left-click?

Click should work on a primary key but it is also working for other keys also. I have come across one scenario where pressUp of left-clicking is getting missed and that is creating an issue. steps are as follows:

  1. left mouseDown on the object.
  2. right mouseDown on the same object.
  3. right pressUp on the object.

If we follow this order, left pressUp is getting missed it is not getting fired nor it is present after that point. It's like it totally vanishes as if it never existed.

Can anyone please help me with this? Thank you in advance!!

Upvotes: 0

Views: 86

Answers (1)

James
James

Reputation: 2787

I am kind confused with your question, but I think a easy way to ignore the right click event is to use event.preventDefault for contextmenu.

The preventDefault() method of the Event interface tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be.

For example (you may not able to show the right click menu in the example):

document.addEventListener('contextmenu', function() {
  event.preventDefault();
  return false;

})

Upvotes: 0

Related Questions