Javascript HTML5画布。。。为什么OnMouseDown不能使用以下代码
正在尝试获取以下代码以在MouseDown上启动新路径,但没有成功。。。提前谢谢Javascript HTML5画布。。。为什么OnMouseDown不能使用以下代码,javascript,html,canvas,onmousedown,Javascript,Html,Canvas,Onmousedown,正在尝试获取以下代码以在MouseDown上启动新路径,但没有成功。。。提前谢谢 mousemoveHandler: function(inSender, e) { if ( (this.owner.dragging) && (this.hasNode()) ) { var can = this.node; var ctx = can.getContext('2d');
mousemoveHandler: function(inSender, e) {
if ( (this.owner.dragging) && (this.hasNode()) ) {
var can = this.node;
var ctx = can.getContext('2d');
//ctx.beginPath();
//c.fillStyle = "blue";
//ctx.fillRect(e.offsetX,e.offsetY,10,10);
ctx.lineWidth = 3;//BRUSH WIDTH
ctx.lineJoin = 'round';//round miter bevel
ctx.lineCap = 'round';//butt round square
ctx.strokeStyle = '#AB1616';
ctx.lineTo(e.offsetX,e.offsetY);
ctx.stroke();
ctx.restore();
}
},
mousedownHandler: function(inSender, e){
if ((this.owner.dragging) && (this.hasNode())) {
ctx.beginPath();
ctx.moveTo(e.offsetX,e.offsetY);
}
}
可能是因为该代码中没有分配
onmousedown
事件处理程序,而且语法上也不正确。修复程序是onmousedown处理程序mousedownHandler:function(inSender,e){if(!this.owner.drawing)&(this.hasNode()){…code…}