手机
当前位置:查字典教程网 >网页设计 >HTML5教程 >使用jTopo给Html5 Canva中绘制的元素添加鼠标事件
使用jTopo给Html5 Canva中绘制的元素添加鼠标事件
摘要:使用Html5的时候,在Canvas上绘制的东西是不能相应鼠标事件的,但是使用jTopo添加事件非常简单,效果如下:代码示例:varnode...

使用Html5的时候,在Canvas上绘制的东西是不能相应鼠标事件的,但是使用jTopo添加事件非常简单,效果如下:

1

代码示例:

var node = new JTopo.Node("Hello");

node.setLocation(409, 269);

node.mousedown(function(event){

if(event.button == 2){

node.text = '按下右键';

}else if(event.button == 1){

node.text = '按下中键';

}else if(event.button == 0){

node.text = '按下左键';

}

});

node.mouseup(function(event){

if(event.button == 2){

node.text = '松开右键';

}else if(event.button == 1){

node.text = '松开中键';

}else if(event.button == 0){

node.text = '松开左键';

}

});

node.click(function(event){

console.log("单击");

});

node.dbclick(function(event){

console.log("双击");

});

node.mousedrag(function(event){

console.log("拖拽");

});

node.mouseover(function(event){

console.log("mouseover");

});

node.mousemove(function(event){

console.log("mousemove");

});

node.mouseout(function(event){

console.log("mouseout");

});

【使用jTopo给Html5 Canva中绘制的元素添加鼠标事件】相关文章:

用html5绘制折线图的实例代码

介绍HTML5中的文件导入

移动端html5 meta标签的神奇功效

html5绘制时钟动画

详解如何用HTML5 Canvas API控制图片的缩放变换

使用canvas绘制超炫时钟

HTML5 canvas基本绘图之绘制线段

实例讲解使用HTML5 Canvas绘制阴影效果的方法

html5 svg 中元素点击事件添加方法

调用HTML5的Canvas API绘制图形的快速入门指南

精品推荐
分类导航