我正在尝试使用多个鼠标事件侦听器。其中包括mousedown和contextmenu。我的问题是,当我要运行contextmenu侦听器时,mousedown事件也会运行。
我认为您可以确定事件的发生,只是不确定语法。这是我计划要做的:
$("#temp_canv").mousedown(e => {this.line_down(e);});
$("#temp_canv").contextmenu(e => {
e.preventDefault();
//...*context menu code*
});
line_down(e)
{
if(e.*whatever will give me the events associated does not have contextmenu as well.* != contextmenu) //<--not sure of the syntax
{
//*Run only line_down events that are not associated with context menu*
}
}
我找到了答案。原来,您只需要右键单击“ if(e.button == 0)”即可。就这么简单。