程序员

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

作者:admin 2021-08-07 我要评论

使用Html5的时候,在Canvas上绘制的东西是不能相应鼠标事件的,但是使用jTopo添加事件非常简单,效果如下: 代码示例: 复制代码 代码如下: var node = new JTop...

在说正事之前,我要推荐一个福利:你还在原价购买阿里云、腾讯云、华为云服务器吗?那太亏啦!来这里,新购、升级、续费都打折,能够为您省60%的钱呢!2核4G企业级云服务器低至69元/年,点击进去看看吧>>>)
使用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");
});

原文链接:https://m.jb51.net/html5/166071.html

版权声明:本文转载自网络,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。本站转载出于传播更多优秀技术知识之目的,如有侵权请联系QQ/微信:153890879删除

相关文章
  • 使用jTopo给Html5 Canva中绘制的元素添

    使用jTopo给Html5 Canva中绘制的元素添

  • html5中JavaScript removeChild 删除所

    html5中JavaScript removeChild 删除所

  • html5设计原理(推荐收藏)

    html5设计原理(推荐收藏)

  • HTML5 canvas绘制的玫瑰花效果

    HTML5 canvas绘制的玫瑰花效果

腾讯云代理商
精彩导读
海外云服务器
热门资讯
腾讯云代理商