KineticJS: right click fires click
Asked Answered
M

1

3

I'm using Kineticjs and I'm defining a rect event like this

this.rect.on('click tap', function(){
foo();
});

The event is fired when I left-click, but also when right-click. How can I avoid to fire this event with right-click? (I can't disabled the right-click in the page because I want to open a context menu if I rightclick over the rect)

Thank you

Moffit answered 23/2, 2013 at 11:18 Comment(0)
S
9

You need to filter out right mouse click

this.rect.on('click tap', function(e){ 
   // 1:left, 2: middle, 3: right, for IE 8, e.button != 2
   if (e.which != 3) {
      foo();
   }
}
Shooin answered 23/2, 2013 at 16:50 Comment(1)
accepted! Sorry, It was my first question and I didn't know that i have to do thatMoffit

© 2022 - 2024 — McMap. All rights reserved.