KineticJS: right click fires click

扶醉桌前 提交于 2019-12-10 09:43:50

问题


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


回答1:


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();
   }
}


来源:https://stackoverflow.com/questions/15039915/kineticjs-right-click-fires-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!