Tuesday, August 14, 2018

Re: Add Mouse Events for Canvas Drawing

While you can paint an image into the canvas, the canvas itself is just pixel. When you click on the canvas you actually click the rendered pixel and not the image instance used to paint these pixels into the canvas. So a click handler on the image does not make any sense. 

To work effectively with canvas you usually have to define a model (often called scene graph) that represents what you have painted / want to paint into the canvas. Then you add event handlers to the canvas and when you receive events you use the x/y position to work with / modify your model. Then you re-render the updated model into the canvas.

So usually you want to use some library. Maybe Lienzo suites your needs: 

https://github.com/ahome-it/lienzo-core
https://www.lienzo-core.com/lienzo-ks/

-- J.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment