I'm using GWT-Ext Button's in a form, where I'm trying to detect the
loss of focus on the button, so that focus can return to the start of
the form, instead of somewhere else (like the browser's address bar).
I'm not sure whether this is a GWT-Ext problem or my (lack of)
understanding of event handling in GWT.

Out of the box unfortunately, I didn't find a way to catch focus
events like GWT's Button, which can have a FocusListener, so I had a
go at catching the ONBLUR event for a GWT-Ext Button with the
following code:

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FocusListener;
import com.gwtext.client.widgets.Button;

public class FocusExtButton extends Button {

        protected FocusListener focusListener = null;

        public FocusExtButton() {
                super();
                sinkEvents(Event.ONBLUR | Event.ONFOCUS);
        }

        public FocusExtButton(String text) {
                super(text);
                sinkEvents(Event.ONBLUR | Event.ONFOCUS);
        }


        /**
         * Fire the focus listener's events
         */
        @Override
        public void onBrowserEvent(Event event) {
                System.out.println("event: "+event.getTypeInt());
                super.onBrowserEvent(event);
                if (DOM.eventGetType(event) == Event.ONFOCUS) {
                        if (focusListener != null) focusListener.onFocus(this);
                } else if (DOM.eventGetType(event) == Event.ONBLUR) {
                        if (focusListener != null) 
focusListener.onLostFocus(this);
                }
        }


        /**
         * Set the focus listener to use
         *
         * @param listener
         */
        public void setFocusListener(FocusListener listener) {
                this.focusListener = listener;
        }

}

I'm not sure theres anything wrong with this code, but under both the
GWT Hosted Mode and FF the button doesn't even show up on the GUI.
Changing the button used back into a regular GWT-Ext Button works
fine, taking out the sinkEvents calls also makes the button show up
again. The onBrowserEvent also never fires.

I'm at a bit of a loss on how to achieve this!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to