Hi,

With GWT 2.3 I have been struggling a while with the event handling in
my custom widget.

I have created a custom widget by extending SimplePanel. I am aware
that it is usually better to create a Composite, but I have at least
one reason not to do so in this case. Please do not reply that I
should use a Composite. I am trying to understand the underlying
concepts.

Here is code showing what I try to achieve:

<code>

package se.festivitas.gwt.portal.client.view.dock;

import com.google.gwt.event.dom.client.HasMouseDownHandlers;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.SimplePanel;

public class SimplePanelTest extends SimplePanel {

        class FocusFlowPanel extends FlowPanel implements
HasMouseDownHandlers {

                @Override
                public HandlerRegistration addMouseDownHandler(MouseDownHandler
handler) {
                        return addDomHandler(handler, MouseDownEvent.getType());
                }

        }

        public SimplePanelTest() {
                FocusFlowPanel ffp = new FocusFlowPanel();
                Label lbl = new Label("SimplePanelTest");
                ffp.add(lbl);

                DOM.appendChild(getElement(), ffp.getElement());

                lbl.addMouseDownHandler(new MouseDownHandler() {

                        @Override
                        public void onMouseDown(MouseDownEvent event) {
                                Window.alert("FlowPanel Clicked!");
                        }
                });
        }
}

</code>


When instanciating this widget and adding it to the RootPanel, the
onMouseDown never fires. Why? Is there something I missed?

Adding the MouseDownHandler to the whole widget works: the onMouseDown
fires.

Thank you for any help.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to