-
4 Jun 2012 9:01 PM #1
Unanswered: How to set focus on a field after it displays?
Unanswered: How to set focus on a field after it displays?
I've got a view which animates in from the right with an slide animation.
On that view I have a number field which I want to have focus, so the keyboard is up and ready to be typed on.
But I can't seem to pass the focus to the field. Any thoughts?
In the config of the view I have this code (along with other lines I've missed out):
Code:items: [ { xtype: "numberfield", id: "numPaymentAmount" } ] listeners: { painted: function() { Ext.getCmp("numPaymentAmount").focus(); } }
-
6 Jun 2012 10:13 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
Mobile devices have always had an issue with forcing focus or even blur. Executing focus is the best bet but may nto work. You can try delaying the firing of it to see if some time after the painted event has fired if it can focus.
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.
-
6 Jun 2012 12:50 PM #3
Hmmm. I tried setting the focus on button click, so the view was already rendered and everything, but that worked on my PC but not on the mobile device.
If that doesn't work, it seems I can't set focus on the field at all - not after delay or on button click or on painted.
Oh well.
-
16 Dec 2012 7:28 PM #4
I have fixed this bug
I have fixed this bug
After review Button.js 's code I know how to fix this bug which many people faced the same problem and I do not want to has it alone.
You can add below code in your own tap event method before show another page:
if (e && e.preventDefault) {
e.preventDefault();
}


Reply With Quote