-
24 Sep 2012 1:55 AM #1
Answered: How to catch keypress enter ?
Answered: How to catch keypress enter ?
Hello,
I'm a newbie on gxt3.
I've a form with several field and i want that the "enter" submit my form ?
How do I do that ?
Thks
-
Best Answer Posted by lanciendunet
I've resolved my problem with :
Code:new KeyNav(myTextField) { @Override public void onEnter(NativeEvent evt) { evt.stopPropagation(); evt.preventDefault(); myTextField.finishEditing(); //Do the action } };
-
25 Sep 2012 10:33 PM #2
Any suggestions or examples, pls ?
-
27 Sep 2012 8:09 AM #3
What have you tried? Have you worked with key handlers at all, to see about adding a handler either to each field or to the form in general?
Another idea might be to have a preview handle (see com.google.gwt.user.client.Event.addNativePreviewHandler(NativePreviewHandler)), and watch for all key down events to see if they are an enter key, and if so, submit the form.
Do you use any components where the user is allowed to use the enter key, like a button, or a ComboBox/DateField (where the user can use the keyboard to navigate)? What should happen if the enter key is used there - should it both select that item and submit all at once?
-
27 Sep 2012 11:34 PM #4Ext GWT Premium Member
- Join Date
- Aug 2010
- Location
- Germany, Solingen
- Posts
- 226
- Vote Rating
- 2
- Answers
- 4
Create a new GWT project in Eclipse and check "Generate project samle code".
There you will find the answer of your question.
-
4 Oct 2012 11:00 PM #5
I've resolved my problem with :
Code:new KeyNav(myTextField) { @Override public void onEnter(NativeEvent evt) { evt.stopPropagation(); evt.preventDefault(); myTextField.finishEditing(); //Do the action } };


Reply With Quote