Titanium Community Questions & Answer Archive

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

touch events ignored on both label and views

Can anyone else confirm this as an actual bug? I've tried creating a view with a label inside it. I've created an event handler for the view to monitor 'singletap' and show an alert. Running it on the emulator and nothing happens when i click the view. I've then tried adding that event to the label. Again no result. I've tried creating a label outside of the view and assigning that the touch result. No effect. Lastly (just to debug if the event handlers are even working) i made an imageView and gave it my touch event. It works as expected.

touchEnabled is true for the view and labels.

So can i add touch events for views and labels to my ever growing list of bugs and limitations in titanium?

Please could someone else test this out and confirm.

— asked October 1st 2010 by Alex Borisov
  • android
  • events
  • ignored
  • label
  • labels
  • mobile
  • touch
  • view
  • views
  • win32
0 Comments

5 Answers

  • Accepted Answer

    There was a bug in the CI build a couple of days ago where views were only touchable if they had a click listener. That has been fixed in the newer CI builds.

    — answered October 1st 2010 by Don Thorp
    permalink
    1 Comment
    • Excellent! Thanks :)

      — commented October 1st 2010 by Alex Borisov
  • This bug is still there. If I add a "click" event listener on Scrollable view I can't scroll it on ipad. It works fine on Android. I am using latest titanium studio Titanium Studio, build: 1.0.8.201201262211.

    Thanks,
    Sree

    — answered February 23rd 2012 by sreejith nair
    permalink
    0 Comments
  • Looks like this is a secret inconsistency between iPhone and Android platforms. On iPhone, this works fine (note these code snippets are being run under a tabGroup like KitchenSink's framework for examples):

    var win = Ti.UI.currentWindow;
    win.title = 'Platform Events';
    
    var view = Ti.UI.createView();
    win.add(view);
    
    var lab = Ti.UI.createLabel({
        text: 'Touch me in order to test Events',
        textAlign: 'center'
    });
    view.add(lab);
    
    lab.addEventListener('singletap', function(e) {
        alert('I got a singletap!');
    });
    lab.addEventListener('doubletap', function(e) {
        alert('I got a doubletap');
    });
    

    The event is caught, and the alert will pop up on iPhone for both singletap and doubletap. But, not on android! However, if you add handling for the 'click' event, android comes alive. i.e.:

    var win = Ti.UI.currentWindow;
    win.title = 'Platform Events';
    
    var view = Ti.UI.createView();
    win.add(view);
    
    var lab = Ti.UI.createLabel({
        text: 'Touch me in order to test Events',
        textAlign: 'center'
    });
    view.add(lab);
    
    lab.addEventListener('singletap', function(e) {
        alert('I got a singletap!');
    });
    lab.addEventListener('doubletap', function(e) {
        alert('I got a doubletap');
    });
    //
    //add click handling to kick android in the pants
    //
    lab.addEventListener('click', function(e) {
        alert('I got a click!');
    });
    

    Hope that helps.

    — answered October 1st 2010 by Christopher Rumpf
    permalink
    0 Comments
  • I have a similar problem to alex.

    I have a View that contains a Label and and ImageView.

    I have 3 event listeners attached to the View (singletap, touchstart and touchend)

    The events are fired on iphone as expected and I get the proper results.

    They do not seem to work on Android emulator ( Android 2.3.1). The click event will work on Android though.

    I thought it could be the emulator configuration so I added in touchscreen functionality into the emulator config but still no correct behavior.

    I am using 1.8.1 of Titanium.

    — answered March 15th 2012 by David Cooke
    permalink
    3 Comments
    • If I click many times in a row (i got frustrated) then "singletap" fires and I go to the next screen. The touchstart and touchend events still don't fire but it looks like singletap will work. So perhaps it IS the emulator.

      I took another look at the AVD config and could not find anything obvious that I am missing. I have not tested on a real device.

      — commented March 15th 2012 by David Cooke
    • I ended up adding a os name check using Ti.Platform.osname and if "android" used "click" and for iPad "singletap"

      — commented March 15th 2012 by sreejith nair
    • thanks Sreejith I guess I'll do the same.

      — commented March 15th 2012 by David Cooke
  • There was a bug in the CI build a couple of days ago where views were only touchable if they had a click listener. That has been fixed in the newer CI builds.

    — answered October 1st 2010 by Don Thorp
    permalink
    1 Comment
    • Hi Don

      Your comment is quite useless. I work with Titanium SDK 2.1.2 GA and the problem still exists on Android. Documentation does not state any thing about this issue.
      The solutions with using click event instead of singletap is not workable in any situation.

      — commented September 14th 2012 by Jakub Iwanczuk
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.