如何检测doubletap而不触发sencha touch中的silgeltap

时间:2011-05-02 11:18:32

标签: sencha-touch

是否有一种智能而简单的方法来检测双击而不会在触摸触摸中触发silgeltap?

日Thnx!

1 个答案:

答案 0 :(得分:3)

我认为没有'干净'的方法。它会将单击选项延迟300毫秒,这可能是不可接受的。如果可以,您可能希望简化UI交互。也许点击并按住?

我在Sencha Touch forums

中找到了此代码
setupEventHandlers: function(){
this.mon(this.el, {
    tap: function(e){            
        if(this.delayedTask == null){            
            //setup a delayed task that is called IF double click is not later detected
            this.delayedTask = new Ext.util.DelayedTask(
              function(){
                this.doSomethingInteresting(); 
                this.delayedTask = null;
              }, this);  

            //invoke (with reasonable time to cancel)
            this.delayedTask.delay(300);
        }                
    }, 
    doubletap: function(e){                
        //cancel and clear the queued single click tasks if it's there
        if(this.delayedTask != null){
          this.delayedTask.cancel();
          this.delayedTask = null;
        }                        

        //handle the double click
        this.doSomethingReallyInteresting();
    },        
    scope: this
});

},