Keyboard events ignored for DialogBox in GWT 1.4?

195 views
Skip to first unread message

pas...@gmail.com

unread,
Jun 15, 2007, 11:12:20 AM6/15/07
to Google Web Toolkit
I've been trying to use the onKeyDownPreview() on a DialogBox in my
code with GWT 1.4.10 and no events reach the DialogBox. Apparently the
Mail app example from the RC distribution doesn't work either (try to
hit Escape or Enter on the About box). This used to work on 1.3.

Is this a known bug and is there any workaround?

krispy

unread,
Jun 15, 2007, 12:18:44 PM6/15/07
to Google Web Toolkit
Look at issue 1197:

http://code.google.com/p/google-web-toolkit/issues/detail?id=1197

Looking at the source for PopupPanel.java, the problem is that the
event preview is only allowing the keyboard events to pass through if
the target of the event is the popup or one of its children. Since
the focus of the keyboard is outside of the popup in the Mail
application, it doesn't receive any events. I did get the Escape and
Enter key to work by focusing the Close button of the About box (I did
this by clicking down on the button, then dragging the mouse away from
the button, so that the mouse down event focuses the button). If you
could, you should try to grap the keyboard focus into the popup to
regain event previews.

HTH,

-krispy

pas...@gmail.com

unread,
Jun 18, 2007, 8:51:35 AM6/18/07
to Google Web Toolkit
Thanks for the insight. Based on your explanation and a bit of source
code skimming, I used the following workaround on my DialogBox:

public boolean onEventPreview(Event event) {
if (DOM.eventGetType(event) == Event.ONKEYDOWN) {
return onKeyDownPreview((char) DOM.eventGetKeyCode(event),
KeyboardListenerCollection.getKeyboardModifiers(event));
}
return super.onEventPreview(event);
}

Reply all
Reply to author
Forward
0 new messages