Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11856] Android: touchEnabled false on child view causes longpress event to fire when clicked

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2017-06-13T20:38:45.000+0000
Affected Version/sRelease 2.1.3, Release 2.1.4, Release 3.0.0, Release 3.1.0
Fix Version/sRelease 6.2.0
ComponentsAndroid
Labelsn/a
ReporterNathan Nadeau
AssigneeMaggie Chen
Created2012-10-24T19:54:05.000+0000
Updated2017-08-24T22:48:41.000+0000

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]

Comments

  1. Daniel Sefton 2012-11-26

    Tested and confirmed on Samsung Galaxy S2 TiSDK 2.1.4 GA, 3.0.0 CI.
  2. Carlo Hermus 2012-12-16

    Any ETA on this?
  3. jithinpv 2013-03-14

    Issue reproduces with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) Device: Samsung galaxy s duos Android version: 4.0.4
  4. Neville Dastur 2013-11-09

    Can confirm that this bug exists in SDK 3.1.3 tested on a Samsung S3 It would be good to get this fixed. Quite a few watchers and quite a serious bug
  5. Maggie Chen 2017-06-13

    PR https://github.com/appcelerator/titanium_mobile/pull/9137
  6. Samir Mohammed 2017-06-14

    Updated PR as original branch was deleted: https://github.com/appcelerator/titanium_mobile/pull/9143
  7. Samir Mohammed 2017-06-26

    Verified fix in SDK Version: 6.2.0.v20170626084207. Test and other information can be found at: https://github.com/appcelerator/titanium_mobile/pull/9143

JSON Source