Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Problem with touchstart and button on Android

When I add event "touchstart" to the button, button stops to change it state on Android (For example turns green when i click on it). Any ideas how to fix it?

— asked November 6th 2010 by Dmitry Magunov
  • button
4 Comments
  • Your code please :-/

    — commented November 6th 2010 by Paul Dowsett
  • I'd like to see some sample code as well. I cant even get the touchStart eventListener callback to exeecute at all using the emulator, havent tried on the device yet. "click" fires properly, "touchStart" does not.

    My code here: http://pastie.org/1280885

    — commented November 8th 2010 by Anthony Webb
  • FWIW, what I am trying to do is change the way a button looks whne you press down on a button, a visual indicator that you are pressing the button. If anyone has any samples that can do that I'd love to have a look.

    — commented November 8th 2010 by Anthony Webb
  • My code:

    var buttonAdd = Titanium.UI.createButton({
       title: '+',
       width:100,
       height:60,
       font:{fontSize:24,fontWeight:'bold'},
       top:120
    });
    
    buttonAdd.addEventListener('click',function(e) {
        clearTimers();
        updateValue(lineNumber,1);
        Ti.API.info('click');
    
    });
    
    buttonAdd.addEventListener('doubletap',function(e) {
           updateValue(lineNumber,1);
           clearTimers();
           Ti.API.info('doubletap');
    });
    
    
    buttonAdd.addEventListener('touchstart',function(e) {
        Ti.API.info('touchstart');
        timer=setTimeout(function(){
            startInterval(lineNumber,1);
        }, 500);
    });
    buttonAdd.addEventListener('touchcancel',function(e) {
        clearTimers();
    });
    
    buttonAdd.addEventListener('touchend',function(e) {
        Ti.API.info('touchend');
        clearTimers();
    });
    
    — commented November 9th 2010 by Dmitry Magunov

0 Answers

The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.