It seems that it doesn't really matter.  The DialogBox itself works fine,
and whether I call setFocus() immediately or through a DeferredCommand, the
result is the same.

What is not clear is why there is a KeyUp event fired at all.   I am not
even listening for keyup in the dialog.  I just have a close button that I
give the focus to, so when Enter is pressed, it "auto-clicks" the close
button for me.  This I see is working as expected because I get an onClick
event sent to my button.

I removed the setFocus() call in the onClick() event handler of the dialog's
close button, and then it fires the onClick event as expected and I see no
KeyUp event.

But if I put the setFocus() call in the onClick() event handler of the
dialog's close button, it first fires the onClick event as expected, but I
then get a KeyUp event on the TextField that received the focus (it does
have a KeyUp handler registered).

Here's the close button's onClick code:

        closeButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                Object src = event.getSource();
                GWT.log("ExceptionDialog onClick source: " + src.getClass()
+ "; event: " + event.toDebugString(),null);
                dialog.hide();
                if ( giveFocusBackTo != null )
                {
                    DeferredCommand.addCommand(new Command() {
                        public void execute() {
                            giveFocusBackTo.setFocus(true);
                            giveFocusBackTo = null;
                            return;
                        }
                    });
                }
            }
        });

If I comment out the giveFocusBackTo.setFocus(true), it works as expected,
but when I return from the dialog, my field doesn't have the focus that I'd
like it to have.    If I have it like above, I'll get both an onClick and a
KeyUp event:

[INFO] ExceptionDialog onClick source: class
com.google.gwt.user.client.ui.Button; event: event: ClickEvent:
[INFO] myhandler keyup source: class
com.google.gwt.user.client.ui.PasswordTextBox; event: event:
KeyUpEvent:[13];

So the question is why does setting the focus in the dialog box cause a
KeyUp event to fire, but if I don't do the focus, only the click occurs and
no keyup event occurs?

--~--~---------~--~----~------------~-------~--~----~
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