1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    58
    Vote Rating
    0
    yogesh1 is on a distinguished road

      0  

    Default Answered: how to handle keyboard "enter" and "tap" event on same button.

    Answered: how to handle keyboard "enter" and "tap" event on same button.


    hi,

    i am new to this world of sencha touch.
    i want a button to listen on enter key pressed on keyboard as well as on tap event of sencha touch.
    "tap" event for button is working fine its calling addToBucket function only once.
    i have tried giving action event to function addToBucket on keyboard enter button pressed on the panel.
    it works fine for 1st time but afterwards same function is getting called multiple times when enter button is pressed.

    screenPanel: {
    initialize: 'onInitializeScreenPanel',
    action: 'addToBucket'
    },

    how can i restrict this multiple call of same function on enter key pressed or is their any way to handle "Enter" key press event in sencha touch 2...?

    thanks in advance..

  2. Quote Originally Posted by yogesh1 View Post
    hi,

    i have 35 textfields on my form. Is it possible to give one keyup event for all the textfields rather than putting it up for every textfield? plz reply with code .
    Code:
    control: {
        '> textfield': {
            keyup: 'onKeyUp'
        }
    }

  3. #2
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    Answers
    41
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    I have this scenario in my search views. So this is how I do it in my controller (MVC):

    Code:
    config: {
            refs: {
                searchField: 'searchview searchfield',
                searchFieldButton: 'searchview button[action=search]'
            },
            control: {
                'searchField': {
                    keyup: 'searchDataStart'
                },
                'searchFieldButton': {
                    tap: 'searchData'
                }
            }
    },
    
    
    searchDataStart: function(fld, e) {
            // 13 = user tapped 'return/enter' button on keyboard
            if (e.browserEvent.keyCode == 13) {
                e.stopEvent();
                this.searchData();
            }
    },
    
    
    searchData: function() {
      var searchValue =  this.getSearchField().getValue();
      // do the search...
    
    
    
    }

  4. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    58
    Vote Rating
    0
    yogesh1 is on a distinguished road

      0  

    Default


    hi,

    but in this scenario the function will call every time the key is been pressed.in my scenario i want to catch "ENTER" key press event.

  5. #4
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    Answers
    41
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    Quote Originally Posted by yogesh1 View Post
    but in this scenario the function will call every time the key is been pressed.in my scenario i want to catch "ENTER" key press event.
    that's true - but a.f.a.I.k. there is no ENTER event...

  6. #5
    Sencha User
    Join Date
    Mar 2013
    Posts
    58
    Vote Rating
    0
    yogesh1 is on a distinguished road

      0  

    Default


    hi,

    i have 35 textfields on my form. Is it possible to give one keyup event for all the textfields rather than putting it up for every textfield? plz reply with code .

  7. #6
    Sencha Premium Member
    Join Date
    Feb 2012
    Location
    Berne, Switzerland
    Posts
    714
    Vote Rating
    42
    Answers
    41
    ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about ingo.hefti has a spectacular aura about

      0  

    Default


    Quote Originally Posted by yogesh1 View Post
    i have 35 textfields on my form. Is it possible to give one keyup event for all the textfields rather than putting it up for every textfield?
    why would you do that this way? is this some kind of game?

  8. #7
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    898
    Answers
    3575
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The action event will fire when you press enter within a form field.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  9. #8
    Sencha User
    Join Date
    Dec 2012
    Posts
    32
    Vote Rating
    3
    Answers
    2
    alanthales is on a distinguished road

      1  

    Default


    Quote Originally Posted by yogesh1 View Post
    hi,

    i have 35 textfields on my form. Is it possible to give one keyup event for all the textfields rather than putting it up for every textfield? plz reply with code .
    Code:
    control: {
        '> textfield': {
            keyup: 'onKeyUp'
        }
    }

  10. #9
    Sencha User
    Join Date
    Mar 2013
    Posts
    58
    Vote Rating
    0
    yogesh1 is on a distinguished road

      0  

    Default


    @ingo.hefti

    no its not game .i have submit form there are 35 fields include select box,textfild. i want to catch that evevnt whenever user press enter button on keyboard in any field.so is that possible to give one "keyup" event to entire form.?plz reply

    @
    mitchellsimoens

    i tried with action event but whenever i press enter that function is been called twice or multiple times.thats why i m tring this approach.plz gv m solution if u have it for that issue?so how should i stop that multiple call?

  11. #10
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    898
    Answers
    3575
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I'm not getting it to fire multiple times if I set a listener directly on the field, on the form and delegate it to the field or in a controller.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.