dojo/mouse提供了鼠标事件中需要的方法。
简介:用来给指定节点(node)绑定鼠标事件
方法:
cancle(node, listener):给节点(node)绑定鼠标'touchcancel'|'mouseleave'
enter(node, listener):给节点(node)绑定鼠标enter or touch
leave(node, listener):给节点(node)绑定鼠标leave or touch
move(node, listener):给节点(node)绑定鼠标或者手指dragged
out(node, listener):给节点(node)绑定鼠标'mouseout' or touch
over(node, listener):给节点(node)绑定鼠标'mouseover' or touch
press(node, listener):给节点(node)绑定鼠标或'touchstart'|'mousedown'
release(node, listener):给节点(node)绑定鼠标按下之后释放
实例代码如下:
1 <!DOCTYPE html> 2 <html > 3 <head> 4 <style type="text/css"> 5 @import url("http://localhost/arcgis_js_api/library/3.12/3.12/dijit/themes/claro/claro.css"); 6 </style> 7 <script type="text/javascript"> 8 var dojoConfig = { 9 isDebug: true, // 调试 10 async: true, 11 parseOnLoad: false 12 }; 13 </script> 14 <script type="text/javascript" src="http://localhost/arcgis_js_api/library/3.12/3.12/init.js"></script> 15 <script> 16 require([ 17 "dojo/ready", 18 "dojo/mouse", 19 "dojo/touch", 20 "dojo/on", 21 "dojo/dom", 22 "dojox/image/LightboxNano", 23 "dijit/layout/ContentPane", 24 "dijit/form/Button", 25 "dojo/domReady!" 26 ], function (ready,mouse,touch,on,dom,LightboxNano,ContentPane,Button) { 27 var btn = new Button({ 28 label:"Button" 29 },"btn"); 30 touch.over(btn,function(){ 31 alert("touch.over"); 32 }); 33 }); 34 </script> 35 </head> 36 <body class="claro"> 37 <div id="btn"></div> 38 </div> 39 </body> 40 </html>