views:

230

answers:

2

May be a dumb question, but GWT FlowPanel (raw div element) does not provides something to handle a mouseclick/mousemovement on it. Overriding onBrowserEvent do not works either.

If setting onclick event using native JavaScript (need to specify positive height before, 'div' have a height of 0 if not specified), then catching these events is working properly. Is there a way to do it without using JSNI?

A: 

Seems question is a dumb one, yes. FlowPanel can be easily wrapped or replaced with FocusPanel, which provides a lot of method for monitoring/handling events.

shaman.sir
Well, if I understand FlowPanel and FocusPanel corrrectly, you can't replace FlowPanel by FocusPanel but you can sure wrap a FlowPanel in a FocusPanel.
Zwik
Yes, `FocusPanel` is `SimplePanel` implementation, so it can not contain more than one child widget. But if your `FlowPanel` contains only one, you can simply replace it with `FocusPanel` :).
shaman.sir
Well, using a FlowPanel for only 1 child would be useless.
Zwik
+3  A: 

What you need to do here is wrap your FlowPanel in a FocusPanel. A FocusPanel contain all possible handler and thus will enable you to have a ClickHandler set to it.

Another method would be to create your own widget extending the flowpanel and implementing the necessary interface in order to be able to contain a ClickHandler.

I personally would recommend the first method. It's simpler, faster to code and won't slow down your application.

Zwik