2013-05-02 46 views
0

我有一个应用程序与旋转木马。在所有轮播页面上都有诸如按钮和日期选择器等元素。我想使用Sencha Touch来处理这些元素上的tapStart事件,但是我一直无法找到任何让我做到这一点的事情。在按钮上处理tapStart事件

有没有人有想法?

UPDATE

我问的煎茶论坛这个问题为好。这里是链接到煎茶论坛主题:http://www.sencha.com/forum/showthread.php?262804-Handle-tapStart-Event-on-a-button&p=963782#post963782

+0

你有什么代码这么远? – Chris 2013-05-02 22:12:06

+0

@ChrisBain这是我的问题其实,我真的没有任何代码。我所有的是在旋转木马的每个容器上都有各种元素的旋转木马。 – 2013-05-03 01:12:15

回答

0

我想出了一个解决我的问题从煎茶触摸论坛上寻求帮助的任何元素。

首先我使用initConfig函数初始化我的容器配置。

Ext.define('MyApp.view.ViewName', { 
    ... 
    // Very Important, this is what I use in the controller to handle the events 
    xtype: 'myxtype', 
    ... 
    initConfig: function() { 
     var me = this; 
     this.config = { 
      ... 
      items: { 
       ... 
       { 
        xtype: 'button', 
        ... 
        listeners: { 
         element: 'element', 

         // This is where my code handles the tapstart 
         // (touchstart) event 
         touchstart: function() { 
          // Fire an event on the controller (me) 
          me.fireEvent('buttondown'); 
         } 
        } 
       }, 
       ... 
      } 
     } 
     this.callParent([this.config]); // Very Important when using initConfig 
    } 
}); 

然后,在我的控制,我添加以下代码:

Ext.define('MyApp.controller.MainController', { 
    ... 
    config: { 
     views: [ 
      'ViewName', 
      ... 
     ], 
     ... 
    }, 
    ... 
    init: function() { 
     this.control({ 
      'myxtype': { 
       buttondown: this.myFunction 
      } 
     }) 
    }, 

    myFunction: function() { 
     // Do something 
    } 
});