使用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");
});
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!!
点击进行留言回复
相关文章:
-
-
-
-
-
-
-
HTML入门
HTML概述 HTML: Hyper Text Markup Language 超文本标记语言 超文本: 比普通文本功能更加强大,可以添加各种样式 标记...
[阅读全文]
-
使用HTML设计商城首页
网站首页 需求分析 根据产品文档,完成商城首页,显示效果如图 技术分析 表格标签table table标签 常用的属性: bgcolor : 背景色 w...
[阅读全文]
-
使用HTML设计注册界面
网站注册页面案例 需求分析 编写一个HTML页面, 显示效果如图所示 技术分析 表单标签 action : 直接提交的地址 method : get 方...
[阅读全文]
-
-
网友评论