简体   繁体   中英

Sencha Touch autofocus on the textfield

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

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

{
                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.

获取该文本字段的引用,而不是使用select选择焦点。

this.getSeachField().select();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM