我意识到我对这个问题来得有点晚,但是为了一个个人项目,我需要一个解决方案,所以我进行了一些研究,并发现了如何使链接工作,并且进行了彻底的测试。以下是我的结果:
例如,使用this.can.onmousedown进行链接:
this.can.onmousedown = this.Area2OnMouseDown01.bind(this)
this.can.onmousedown = this.Area2OnMouseDownXX.bind(this)
does not work. In this case, only Area2OnMouseDown01 is called.
使用this.can.addEventListener("mousedown", ...)进行链接,例如:
this.can.addEventListener ("mousedown", this.Area2OnMouseDown01.bind(this), false);
this.can.addEventListenner ("mousedown", this.Area2OnMouseDownXX.bind(this), false);
does work.
注意。它们被定义的顺序决定了它们随后被调用的顺序。
例如,使用上述定义:
- Area2OnMouseDown01 is called first
- Area2OnMouseDownXX is called second
If the order defined above is reversed, the order they are then called is
reversed. For example:
- Area2OnMouseDownXX is called first
- Area2OnMouseDown01 is called second
调用的函数不需要指定任何特定的返回值,例如:
- return false;
- return true;
just simply return:
- return;
If you omit to specify return at the end of the function, javascript automatically inserts return.
被调用的函数不需要以任何其他方式进行修改。例如,这里是我使用的实际函数的简化版本:
canvasChart.prototype.Area2OnMouseDown01 = function(e) {
this.parm.mouse = getMouseCoordinates (this.can, e);
this.parm.mouseX = this.mouseX = this.parm.mouse.x;
this.parm.mouseY = this.mouseY = this.parm.mouse.y;
for (var i = 0; i < this.o.yAxis.data.categories.length; i++) {
if (this.parm.mouseX >= this.o.yAxis.data.categories[i][yid + (i + 1)].x &&
this.parm.mouseX <= this.o.yAxis.data.categories[i][yid + (i + 1)].x +
this.o.yAxis.data.categories[i][yid + (i + 1)].w &&
this.parm.mouseY >= this.o.yAxis.data.categories[i][yid + (i + 1)].y -
this.o.yAxis.data.categories[i][yid + (i + 1)].h &&
this.parm.mouseY <= this.o.yAxis.data.categories[i][yid + (i + 1)].y) {
return;
}
}
return;
}
canvasChart.prototype.Area2OnMouseDownXX = function(e) {
this.parm.mouse = getMouseCoordinates (this.can, e);
this.parm.mouseX = this.mouseX = this.parm.mouse.x;
this.parm.mouseY = this.mouseY = this.parm.mouse.y;
if (this.parm.mouseX >= this.o.yAxis.data.control.x &&
this.parm.mouseX <= this.o.yAxis.data.control.x +
this.o.yAxis.data.control.w &&
this.parm.mouseY >= this.o.yAxis.data.control.y -
this.o.yAxis.data.control.h &&
this.parm.mouseY <= this.o.yAxis.data.control.y) {
return;
}
return;
}