Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3476] Android: UI.ScrollableView - only scroll event fires. No others work (possibly desired behavior)

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-09-11T03:27:42.000+0000
Affected Version/sRelease 1.6.0
Fix Version/sRelease 2.0.1
ComponentsAndroid
Labelsmodule_scrollableview, qe-review, qe-testadded
ReporterPaul Dowsett
AssigneeNeeraj Gupta
Created2011-04-15T03:45:41.000+0000
Updated2012-09-11T03:27:42.000+0000

Description

Problem

None of the events listed in [Titanium.UI.ScrollableView](http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.ScrollableView-object) fire, with the exception of the scroll event. This ticket has been raised to acknowledge the behavior. Note that there is an opinion that this behavior is desired, as some events can be easily confused with scroll when user gestures are performed. Possibly scrollableView should only have one or two events (scroll and click). When other events are needed, additional views can be added. See the workaround below for an example. To resolve this ticket, either the behavior should be modified, or the API docs corrected.

Test case

Results for both android and ios are inline.
var win = Ti.UI.createWindow();
 
var view1 = Ti.UI.createView({backgroundColor:'red', touchEnabled:false});
var view2 = Ti.UI.createView({backgroundColor:'blue', touchEnabled:false});
var view3 = Ti.UI.createView({backgroundColor:'green', touchEnabled:false});
var scrollableView = Ti.UI.createScrollableView({
    views:[view1,view2,view3]
});
win.add(scrollableView);


scrollableView.addEventListener('click', function() {
    Ti.API.info('Click event heard');
});

// ios
scrollableView.addEventListener('dblclick', function() {
    Ti.API.info('dblclick event heard');
});

// ios
scrollableView.addEventListener('doubletap', function() {
    Ti.API.info('doubletap event heard');
});


scrollableView.addEventListener('longclick', function() {
    Ti.API.info('longclick event heard');
});

// ios
scrollableView.addEventListener('longpress', function() {
    Ti.API.info('longpress event heard');
});

scrollableView.addEventListener('pinch', function() {
    Ti.API.info('pinch event heard');
});

// ios
scrollableView.addEventListener('singletap', function() {
    Ti.API.info('singletap event heard');
});

// ios
// android
scrollableView.addEventListener('scroll', function() {
    Ti.API.info('scroll event heard');
});


scrollableView.addEventListener('scrollEnd', function() {
    Ti.API.info('scrollEnd event heard');
});


scrollableView.addEventListener('swipe', function() {
    Ti.API.info('swipe event heard');
});


scrollableView.addEventListener('touchcancel', function() {
    Ti.API.info('touchcancel event heard');
});

scrollableView.addEventListener('touchend', function() {
    Ti.API.info('touchend event heard');
});

scrollableView.addEventListener('touchmove', function() {
    Ti.API.info('touchmove event heard');
});

// ios
scrollableView.addEventListener('touchstart', function() {
    Ti.API.info('touchstart event heard');
});

// ios
scrollableView.addEventListener('twofingertap', function() {
    Ti.API.info('twofingertap event heard');
});

win.open();
So the only caveat to the above workaround is that views have a maximum descendant limit of 12, so already (with the scrollableView, it's child view, and this extra view), 3 views have already been consumed out of this limit. This should not be a problem however, except in some very rare cases, but it's worthwhile keeping it in mind.

Comments

  1. Varun Joshi 2012-05-16

    The issue is resolved in Release 2.0
  2. Satyam Sekhri 2012-08-30

    With reference to updated API docs, verified that only scroll event fired for scrollableview on Android. Verified on: Titanium Studio: 2.1.2.201208281351 Titanium SDK: 2.2.0.v20120828153312 Android Emulator v2.2, Samsung Galaxy Note (v2.3)
  3. Shyam Bhadauria 2012-09-11

    Re-opening to edit label

JSON Source