Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-11856

Android: touchEnabled false on child view causes longpress event to fire when clicked

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: Release 2.1.3, Release 2.1.4, Release 3.0.0, Release 3.1.0
    • Fix Version/s: Release 6.2.0
    • Component/s: Android
    • Labels:
      None
    • Environment:

      Description

      In Android emulator, setting touchEnabled: false on a child view causes a longpress event to fire when a click is performed on the child. Also, when a longpress is performed on the child, you get two longpress events.

      I have a parent view that contains a child view, and I set touchEnabled: false on the child view.

      1) On Android in the emulator, When I do a click on the child view, not only does the parent view receive a click event (expected) but it also receives a longpress event (unexpected). On iOS, the longpress event does not fire on a click (expected).

      2) Not sure if this should be a separate bug report, so I'll mention it here first: Additionally, when I actually do a longpress on the child view, I get two longpress events on the parent, instead of the expected single event.

      If I set touchEnabled: true on the child view, then things work as expected in Android in both above cases.

      The following code can be pasted into app.js to illustrate the problem:

      var win = Ti.UI.createWindow({backgroundColor: 'white', layout: 'vertical'});
       
      var parentView = Ti.UI.createView({
         top:10,
         width:'90%',
         height:'90%',
         backgroundColor:'blue',
         layout: 'vertical',
         id: 'parent'
      });
      parentView.addEventListener('click',function(e){
         alert('parent click: e.source: ' + e.source.id + ', this: ' + this.id);
         Ti.API.info('parent click: e.source: ' + e.source.id + ', this: ' + this.id);
      });
      parentView.addEventListener('longpress',function(e){
         alert('parent longpress: e.source: ' + e.source.id + ', this: ' + this.id);
         Ti.API.info('parent longpress: e.source: ' + e.source.id + ', this: ' + this.id);
      });
       
      var childView = Ti.UI.createView({
         top: 50,
         width: '50%',
         height: '50%',
         backgroundColor: 'red',
         id: 'child',
         touchEnabled: false
      });
       
      parentView.add(childView);
      win.add(parentView);
      win.open();
      

      Link to related Q&A entry:http://developer.appcelerator.com/question/143926/android-touchenabled-false-on-child-view-causes-longpress-event-to-fire-when-clicked

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mchen Maggie Chen
                Reporter:
                bigotilda Nathan Nadeau
                Reviewer:
                Gary Mathews
                Tester:
                Samir Mohammed
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-15015
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code