Results 1 to 5 of 5

Thread: How to catch keypress enter ?

  1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    17
    Answers
    1
    Vote Rating
    0
      0  

    Default 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

  2. 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
                }
            };

  3. #2
    Sencha User
    Join Date
    Sep 2012
    Posts
    17
    Answers
    1
    Vote Rating
    0
      0  

    Default

    Any suggestions or examples, pls ?

  4. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,737
    Answers
    109
    Vote Rating
    93
      0  

    Default

    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?

  5. #4
    Ext GWT Premium Member
    Join Date
    Aug 2010
    Location
    Germany, Solingen
    Posts
    274
    Answers
    4
    Vote Rating
    3
      0  

    Default

    Create a new GWT project in Eclipse and check "Generate project samle code".

    There you will find the answer of your question.

  6. #5
    Sencha User
    Join Date
    Sep 2012
    Posts
    17
    Answers
    1
    Vote Rating
    0
      0  

    Default

    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
                }
            };

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •