Take the 2-minute tour ×

Using GWT 2.0 I have an entry point that adds two Widgets to a LayoutPanel which in turn is added to the RootLayoutPanel. The Widgets both handle click events and have click events registered to them. The problem is that only the last widget added to the LayoutPanel can actually be clicked. Switch the order in which the widgets are added switches the widget that works. Add mroe widgets and still the only you can click is the last one added to the LayoutPanel.

Any idea why this is? Is there any reasoning behind the behaviour, or have I missunderstood what is happening under the covers? How do I gat all widgets in the LayoutPanel to accept events? Should I be using another panel class?

I'm not too bothered if the LayoutPanel prevents anything below it from being clicked, but want all Widgets added to it to be clickable.

share|improve this question
How are you adding the click handlers? Can you paste the relevant code sections? It should work .. I am guessing there is some bug in the way you are adding handlers. –  Sripathi Krishnan Apr 14 '10 at 18:00
This is why I use FocusPanel in these situations - let the GWT team worry about handling the ClickHandlers, not me ;) –  Igor Klimer Apr 14 '10 at 18:11
I've just tried to build a very simplified test case to demonstrate the problem. But the problem didn't apear. I'll update in a minute with more info. –  kerrr Apr 14 '10 at 18:13
add comment

1 Answer

up vote 0 down vote accepted

Stupid Boy! (said in the voice of Captain Mainwaring)

There is no problem having two Widgets on a LayoutPanel accepting clicks. But if you adjust the Widgets' size by manipulating their elements' styles directly then the containing element created by the LayoutPanel will still cover the whole screen. In effect the last Widget added always covered everything else.

GWT school: D- Must try harder. Easily distracted...

share|improve this answer
add comment

Your Answer


