How to implement Enter Key Submit Form in GWT

2,133 views
Skip to first unread message

Néstor Boscán

unread,
Feb 24, 2011, 4:55:06 PM2/24/11
to google-we...@googlegroups.com
Hi

I need to simulate the "Enter Key" submit form in GWT where hay hit the enter key and the form is submitted. Any ideas on how to acomplish this?

Regards,

Néstor Boscán

El Mentecato Mayor

unread,
Feb 25, 2011, 8:59:48 AM2/25/11
to Google Web Toolkit
If you want to do it when a PasswordTextBox is on focus for example
(this is from my sign-in page):

passwordTextBox.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
if (((int)event.getCharCode()) == 13) { // User hit
"Enter" key
submitForm();
}
}
});

Greg Dougherty

unread,
Feb 25, 2011, 9:11:41 AM2/25/11
to Google Web Toolkit
Search for "EnterButton" in this group. At the top is a class
everyone should have. Below that is a discussion of using sinkEvents
to get key down events from Widgets that normally don't pass them.

Greg

On Feb 25, 7:59 am, El Mentecato Mayor <rogelio.flo...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages