头闻号

广州市诚信化工有限公司

瘦身化学品|皮肤用化学品|丰胸化学品|芳香除臭化学品|彩妆化学品|毛发用化学品

首页 > 新闻中心 > 科技常识:使用jTopo给Html5 Canva中绘制的元素添加鼠标事件
科技常识:使用jTopo给Html5 Canva中绘制的元素添加鼠标事件
发布时间:2024-09-30 06:18:33        浏览次数:3        返回列表

今天小编跟大家讲解下有关使用jTopo给Html5 Canva中绘制的元素添加鼠标事件 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了有关使用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"); });

来源:爱蒂网