按钮事件触发下面的processLine JS函数。当第一个警报关闭时,该过程将立即跳至起始行功能。当关闭起始行功能时,该过程立即跳转到结束行功能。当此警报关闭时,将执行context.rectangle。如何使它在第一个事件侦听器处停止,然后等到我将鼠标悬停在画布上才能继续执行startline函数>
function processLine(evt) {
alert("PROCESS "+canvas+" "+evt)
context.fillStyle = "#FF0000";
context.fillRect(0, 0, 150, 75);
toolSelection = "line";
canvas.addEventListener("mousedown",startLine(event));
}
function getMousePos(canvas, evt) {
var rect = canvas.getBoundingClientRect();
return {
x: evt.clientX - rect.left,
y: evt.clientY - rect.top
};
}
function startLine(evt) {
alert("START "+evt.currentTarget)
var pos = getMousePos(canvas, evt);
var posx = pos.x;
var posy = pos.y;
canvas.onmouseup = endLine(event);
}
function endLine(evt) {
alert("END")
var pos = getMousePos(canvas, evt);
var posx = pos.x;
var posy = pos.y;
}