-
31 Mar 2013 11:00 PM #1
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..
-
Best Answer Posted by alanthales
-
1 Apr 2013 1:55 AM #2Sencha Premium Member
- Join Date
- Feb 2012
- Location
- Berne, Switzerland
- Posts
- 591
- Vote Rating
- 34
- Answers
- 35
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... }
-
1 Apr 2013 2:05 AM #3
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.
-
1 Apr 2013 2:57 AM #4Sencha Premium Member
- Join Date
- Feb 2012
- Location
- Berne, Switzerland
- Posts
- 591
- Vote Rating
- 34
- Answers
- 35
-
1 Apr 2013 3:10 AM #5
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 .
-
1 Apr 2013 3:44 AM #6Sencha Premium Member
- Join Date
- Feb 2012
- Location
- Berne, Switzerland
- Posts
- 591
- Vote Rating
- 34
- Answers
- 35
-
1 Apr 2013 5:06 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
- Answers
- 3160
The action event will fire when you press enter within a form field.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
1 Apr 2013 6:23 PM #8
-
1 Apr 2013 6:49 PM #9
@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?
-
2 Apr 2013 5:00 AM #10Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,121
- Vote Rating
- 453
- Answers
- 3160
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
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.


Reply With Quote