How to add a GWT click listener to an Image?

You should be able to just add a ClickHandler (or a MouseDownHandler if that fits your needs better).

You should be able to just add a ClickHandler (or a MouseDownHandler if that fits your needs better). Like this: colorImage. AddClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { // Do something.... } }).

I tried this before but this does not work. I tried different handlers, FocusWidget, ... no reaction. – Paulus Dec 30 '09 at 17:52 @Paulus: In a project I am currently working on I do exactly this but with a MouseDownHandler (addMouseDownHandler) and it works great, click handlers should work equally good.

Please post some more code where you actually try it out but fail. Maybe it is just a stupid typo or something. – Fredrik Dec 30 '09 at 18:25 Thanks for your help.

I updated my question with a demo suited for onModuleLoad() that shows that this solution don't work. – Paulus Dec 31 '09 at 2:22 1 @Paulus: It could be that you are just using the element (why? That is not how GWT should be used when building a UI).

I guess if you bypass everything GWT does for you you will just have have to add handlers and scripts to the element yourself as well. – Fredrik Dec 31 '09 at 6:53 @Fredrik is correct, do not insert just the element. Elements are just tags that show up in the dom, Widgets add in the event support.

Actually adding the Image widget to the RootPanel will correctly attach the handlers. – Colin Alworth Nov 1 at 20:21.

Did you tried to add image. SinkEvents( Event. ONCLICK | Event.

MOUSEEVENTS )?

The image has to be inside a focus widget. I don't know why that is, but somewhere the events don't get propagated right and the DOM events don't fire.

Don't unwrap your widget and append only the DOM elements. The Widget class allows your code to refer to both elements and events at the same time, and deals with possible memory leaks, as well as grouping your code in logical ways. This might make sense for other frameworks, but in GWT you almost always want to work with the Widgets directly, adding them together, then appending them to the RootPanel.

If you really want to use a html table to build this up, look at the com.google.gwt.user.clien" rel="nofollow">com.google.gwt.user.clien" rel="nofollow">com.google.gwt.user.clien" rel="nofollow">com.google.gwt.user.client.ui. HTMLTable subclasses, com.google.gwt.user.clien" rel="nofollow">com.google.gwt.user.clien" rel="nofollow">com.google.gwt.user.clien" rel="nofollow">com.google.gwt.user.client.ui. Grid and com.google.gwt.user.clien" rel="nofollow">com.google.gwt.user.clien" rel="nofollow">com.google.gwt.user.clien" rel="nofollow">com.google.gwt.user.client.ui.FlexTable.

This probably should never be necessary, unless you are adding multiple items to the table - when trying to specify layouts, use actual layout classes.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions