HTML5 canvas object events [closed]
Is开发者_如何学Python there a way to attach an event handler to a object drawn on HTML5 Canvas, without tracking the points?
Try Kinetic JS
http://www.html5canvastutorials.com/advanced/html5-canvas-path-mouseover/
You might also take a look at KineticJS - it was designed to make attaching event listeners to shapes on the screen as simple as possible while sticking to Canvas API patterns. You can check out an example here:
http://www.html5canvastutorials.com/advanced/html5-canvas-path-mouseover/
Take a look at Cake. It's a scene graph plug-in for canvas elements. You should be able to attach event handlers to canvas objects with it.
I think the answer is (but no other poster is using the term) that there is no first-class support for events on graphic primitives drawn on HTML5 canvas. That is not to say that it is not possible to write a listener, merely that if you want to do that you have to use an API like Kinetic JS as can be seen at
http://www.html5canvastutorials.com/advanced/html5-canvas-path-mouseover/
I think, KineticJS should suffice for most of your needs. But make sure that you keep HTML5 originated events away from KineticJS events. I am facing some issues on these lines. will update you if I find something. Regards
精彩评论