I am unable to make autofocus on the sencha touch textfield. I have search icon, when I tap on that icon a textfield will appear Now as soon as it is shown I have to autofocus to that textfield and open the keyboard. Tried setting listeners to main layout as below
我无法在sencha触摸文本字段上进行自动对焦。我有搜索图标,当我点击该图标时会出现一个文本字段现在一旦显示我就必须自动对焦到该文本字段并打开键盘。尝试将侦听器设置为主布局,如下所示
listeners : {
show:function(){
Ext.ComponentQuery.query('searchlist #searchAreaOverlay')[0].element.down('input').dom.focus();
setTimeout(function(){Keyboard.hide();Keyboard.show();},500);
}
},
Also tried setting painted listener function of textfield as below
还尝试设置textfield的绘制监听功能如下
{
xtype : 'textfield',
itemId : 'searchAreaOverlay',
id : 'searchAreaOverlay',
layout : 'fit',
placeHolder:'Search',
inputCls:'searchfiledInputCls',
listeners : {
painted: function(){
Ext.ComponentQuery.query('searchlist #searchAreaOverlay')[0].element.down('input').dom.focus();
setTimeout(Keyboard.show(),100);
},
}
}
Nothing is working.
没有什么工作。
1 个解决方案
#1
0
Get reference of that text field and instead of focus use select.
获取该文本字段的引用,而不是焦点使用选择。
this.getSeachField().select();
#1
0
Get reference of that text field and instead of focus use select.
获取该文本字段的引用,而不是焦点使用选择。
this.getSeachField().select();