2012-11-26 27 views
3

我正在努力開發一個pin代碼面板。當面板被激活時,我希望第一個字段被聚焦/激活,當輸入一個數字時,進入下一個字段,然後在最後一個字段上提交。這應該與iPhone/Android鎖定屏幕類似。自動進展到Sencha Touch 2.1的下一個領域

我一直在嘗試幾個小時,不能解決它。看起來很簡單!非常感謝的幫助。

Ext.define('MyApp.view.PinPanel', { 
    extend: 'Ext.form.Panel', 
    alias: 'widget.pinpanel', 

    config: { 
     centered: true, 
     height: '100px', 
     width: '300px', 
     hideOnMaskTap: true, 
     layout: { 
      type: 'hbox' 
     }, 
     modal: true, 
     items: [ 
      { 
       xtype: 'numberfield', 
       margin: '0 10 0 0', 
       width: 50, 
       clearIcon: false, 
       name: 'pin0', 
       tabIndex: 1 
      }, 
      { 
       xtype: 'numberfield', 
       margin: '0 10 0 0', 
       width: 50, 
       clearIcon: false, 
       name: 'pin1', 
       tabIndex: 2 
      }, 
      { 
       xtype: 'numberfield', 
       margin: '0 10 0 0', 
       width: 50, 
       clearIcon: false, 
       name: 'pin2', 
       tabIndex: 3 
      }, 
      { 
       xtype: 'numberfield', 
       width: 50, 
       clearIcon: false, 
       name: 'pin3', 
       tabIndex: 4 
      } 
     ] 
    } 

}); 

回答

4

在這裏你去:http://www.senchafiddle.com/#Oec2J

的事情是增加每一個numberfield聽衆keyup並設置重點下一個使用tabIndex

+0

這是現貨。非常感謝。也使用Sencha小提琴thumbsup。 – Simon

+0

太棒了!我將來需要這個應用程序,非常感謝! – weerd2

+0

它可以在iOS上使用嗎? –