1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    17
    Vote Rating
    0
    Answers
    1
    lanciendunet is on a distinguished road

      0  

    Default 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

  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
    Vote Rating
    0
    Answers
    1
    lanciendunet is on a distinguished road

      0  

    Default


    Any suggestions or examples, pls ?

  4. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      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
    247
    Vote Rating
    3
    Answers
    4
    gishmo is on a distinguished road

      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
    Vote Rating
    0
    Answers
    1
    lanciendunet is on a distinguished road

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

Thread Participants: 2