1

I am working at an Android app in Titanium. My question is how to implement long touch in Titanium? I need something like this: when user keep pressed a certain view to call some function. I tried this :

arrowright.addEventListener('touchstart', function(e) {
        touched = true;
        setTimeout(function() {
            if (touched) {
                arrowright.fireEvent('longTouch');
            }
        },100);
    });

arrowright.addEventListener('touchmove', function(e) {
    touched = false;
});

arrowright.addEventListener('touchend', function(e) {
    touched = false;
});

arrowright.addEventListener('longTouch',function(){
                          clickTheView(e);
                         },
                         false);

but this is not working like I want. My function clickTheView(e) is call every time I click the view and it is not called when I touch for a long time the view.

Any idea is welcome. Thanks in advance.

Gabrielle
  • 4,933
  • 13
  • 62
  • 122

1 Answers1

0

If you have the latest Ti SDK its included. See http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Button.longpress-event.html

DannyM
  • 466
  • 2
  • 8