On 11 nov, 02:40, Yozons Support on Gmail <[email protected]> wrote:
> 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.
That's weird! This means the "click" of the button isn't triggered by
the keyup by the browser but by some other event (keydown, or keypress
or equivalent). It means that even if you used a Timer to delay the
setFocus a bit more than what the DeferredCommand do it wouldn't work,
for instance if you keep the key depressed before releasing it (the
timer could fire before you release the key).
> 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.
[...]
> 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 set the focus while the key is down, so when you release it, a
keyup event is fired, and because the focus is on the textbox this
event is dispatched to the textbox. If you don't move the focus, the
keyup event is fired at the button, but you don't listened keyup
events there, so you don't see it.
That's just how your browser work, and as I said, this kind of
behavior is being discussed at the W3C (so future versions of browsers
will hopefully align on a predictable behavior).
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---