Results 1 to 3 of 3

Thread: Sench Touch: What is the Easiest Way to Prevent Multiple Taps on Ext.Button

  1. #1
    Sencha User
    Join Date
    Apr 2014
    Posts
    13
    Answers
    1

    Default Answered: Sench Touch: What is the Easiest Way to Prevent Multiple Taps on Ext.Button

    I am developing a Sencha Touch game, but I have huge issue with multiple button taps by users.
    I want a simple code/property to add in app.js so that even if a user taps a Button many times, or presses long time, Sencha Touch executes only 1 single tap event and not multiple events.

    I have checked these links, but they did not help me:http://www.monkian.com/post/27481341...sencha-touch-2
    http://dionbeetson.blogspot.de/2012/...nd-tricks.html
    http://www.sencha.com/forum/showthre...taps-issue-BUG
    http://stackoverflow.com/questions/5...n-sencha-touch
    http://www.sencha.com/forum/showthread.php?105239-Tap-doubletap-amp-taphold-on-one-component





    Bitcoinmillionaire
    Web app Beta:
    http://www.bitcoinmillionaire-app.com
    Android app Beta: http://goo.gl/V7ZqgJ
    iOS app Beta: http://bitcoinmillionaire-app.launchrock.com/

  2. I think it would be very hard to have a generic solution in app.js, etc. that is optimal for every button, since each has a different handler and purpose.

    For me, handling it on a case-by-case basis in the controller's tap handler is best. The reason is that often times you have asynchronous code that can vary in duration so you want to keep the button unclickable until there's a resolution. So for example:

    Code:
    Ext.define('MyApp.controller.MyController', {
      extend: 'Ext.app.Controller',
    
      config: {
        control: {
          '#myButton': {
            tap: 'onMyButtonTap'
          }
        }
      },
    
      onMyButtonTap: function(myButton){
        myButton.disable();
    
        // myModel.save({
        Ext.Ajax.request({
          callback: function(){
            if(myButton){
              myButton.enable();
            }
          },
          // other callbacks
        });
      }
    });
    I am curious why those other solutions didn't work for you. Attaching a tap handler to all buttons, disabling and then re-enabling after a timer seems generic and elegant - although bound to not fit each situation optimally...

  3. #2
    Sencha Premium User
    Join Date
    May 2011
    Location
    Gainesville, FL
    Posts
    228
    Answers
    29

    Default

    I think it would be very hard to have a generic solution in app.js, etc. that is optimal for every button, since each has a different handler and purpose.

    For me, handling it on a case-by-case basis in the controller's tap handler is best. The reason is that often times you have asynchronous code that can vary in duration so you want to keep the button unclickable until there's a resolution. So for example:

    Code:
    Ext.define('MyApp.controller.MyController', {
      extend: 'Ext.app.Controller',
    
      config: {
        control: {
          '#myButton': {
            tap: 'onMyButtonTap'
          }
        }
      },
    
      onMyButtonTap: function(myButton){
        myButton.disable();
    
        // myModel.save({
        Ext.Ajax.request({
          callback: function(){
            if(myButton){
              myButton.enable();
            }
          },
          // other callbacks
        });
      }
    });
    I am curious why those other solutions didn't work for you. Attaching a tap handler to all buttons, disabling and then re-enabling after a timer seems generic and elegant - although bound to not fit each situation optimally...

  4. #3
    Sencha User
    Join Date
    Apr 2014
    Posts
    13
    Answers
    1

    Default

    Thanks a lot Fischer. I used button.disable() and button.enable() and it worked.BitcoinmillionaireWeb app Beta: http://www.bitcoinmillionaire-app.comAndroid app Beta: http://goo.gl/V7ZqgJiOS app Beta: http://bitcoinmillionaire-app.launchrock.com/

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •