Reputation: 113
I have a GWT application containing two canvas instances which are superimposed, i.e. have the same location on screen, one on top of the other. (See http://dev.opera.com/articles/view/html5-canvas-painting, http://html5.litten.com/using-multiple-html5-canvases-as-layers for an example on how it's done. My code is more similar to the second link).
For the lower canvas, I implemented various mouse event handlers - mouseUp, mouseDown, mouseMove etc. I did not implement such handlers for the upper canvas. Also, if that makes any difference, the upper canvas is mostly transparent.
Both canvases has the same parent (a div element).
My problem is that the lower canvas' mouse event handlers do not execute.
My guess is that the upper canvas captures the events, and that they do not propagate to the lower canvas. Do you know a way to work around this? Is there a way to tell a GWT widget to to 'swallow' mouse events?
Thank you!
Upvotes: 3
Views: 1087
Reputation: 53
You can use GWT custom events(GWT Custom Event) to solve this problem.Attach the mouseUp, mouseDown, mouseMove handlers to the upper canvas and Implement Gwt Custom Event Handler to the lower canvas .Now when a MouseUp or MouseDown event is triggered in the upper canvas fire a custom event which will be caught by the lower canvas.Hope this helps
Upvotes: 0