使用jTopo给Html5 Canva中绘制的元素添加鼠标事件

发布时间:2022-04-13 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了使用jTopo给Html5 Canva中绘制的元素添加鼠标事件脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
使用HtML5的时候,在Canvas上绘制的东西是不能相应鼠标事件的,但是使用jTopo添加事件非常简单,效果如下: 

 

代码示例:

复制代码
代码如下:

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中绘制的元素添加鼠标事件全部内容,希望文章能够帮你解决使用jTopo给Html5 Canva中绘制的元素添加鼠标事件所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: