当我单击下面的img并继续进行processToolClick函数时,将执行2个eventListener事件,而不是等待继续之前的mouseup或mousedown事件发生。我已经尝试使用匿名函数和.bind来阻止对processToolClick函数的访问。如何停止onclick并等待mousup或mousedown事件?
<img src="graphicPaneResources/linetool.png" alt="Line Tool" onClick = "processToolClick(this, event)";>
function processToolClick(elem, evt) {
let tmpToolName = elem.src;
tmpToolName = tmpToolName.substring(tmpToolName.lastIndexOf("/")+1);
tmpToolName = tmpToolName.substring(0, tmpToolName.indexOf("."));
switch(tmpToolName) {
case "linetool":
console.log("OK "+tmpToolName+" "+evt)
toolSelection = "linetool";
canvas.addEventListener("onmousedown", lineDrawer.startLine(evt));
canvas.addEventListener("onmouseup", lineDrawer.endLine(evt));
lineDrawer.processLine(evt);
break;
default:
}