Home > Web Front-end > H5 Tutorial > Use jTopo to add mouse events to elements drawn in Html5 Canva_html5 tutorial tips

Use jTopo to add mouse events to elements drawn in Html5 Canva_html5 tutorial tips

WBOY
Release: 2016-05-16 15:47:43
Original
1405 people have browsed it

When using Html5, things drawn on Canvas cannot respond to mouse events, but it is very simple to add events using jTopo. The effect is as follows:



Code example:

Copy code
The code is as follows:

var node = new JTopo.Node("Hello") ;
node.setLocation(409, 269);
node.mousedown(function(event){
if(event.button == 2){
node.text = 'Press the right button' ;
}else if(event.button == 1){
node.text = 'Press the middle button';
}else if(event.button == 0){
node. text = 'Press the left button';
}
});
node.mouseup(function(event){
if(event.button == 2){
node.text = 'Release the right button';
}else if(event.button == 1){
node.text = 'Release the middle button';
}else if(event.button == 0) {
node.text = 'Release the left button';
}
});
node.click(function(event){
console.log("click");
});
node.dbclick(function(event){
console.log("Double-click");
});
node.mousedrag(function(event){
console.log("drag");
});
node.mouseover(function(event){
console.log("mouseover");
});
node.mousemove(function(event){
console.log("mousemove");
});
node.mouseout(function(event){
console.log("mouseout") ;
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template