Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20374] Android: Longpress event on ScrollView doesn't fire

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-04-05T04:27:26.000+0000
Affected Version/sRelease 5.1.2
Fix Version/sn/a
ComponentsAndroid
LabelsAndroid, ScrollView, longpress
ReporterThomas Neerup
AssigneeSrikanth Sombhatla
Created2016-02-09T06:58:15.000+0000
Updated2017-03-21T18:41:49.000+0000

Description

On Android the longpress event don't fire when longpress is performed directly on the ScrollView. In the example below the longpress event is performed when long pressing on the "red" View in the ScrollView but don't fire when long pressing below the View directly on the green ScrollView. If I change onLongpress with onClick the click event fires as expected.
<Alloy>
	<Window backgroundColor="white">
		<ScrollView  backgroundColor="green" onLongpress="onLongPress">
			<View height="100" top="0" backgroundColor="red"></View>
		</ScrollView>
	</Window>
</Alloy>
function onLongPress(e) {
	Ti.API.info('e:' + JSON.stringify(e));
}
$.index.open();

Comments

  1. Srikanth Sombhatla 2016-04-04

    PR: https://github.com/appcelerator/titanium_mobile/pull/7912 Use the following app.js for testing
       var win = Ti.UI.createWindow({ backgroundColor:'white'});
                   
       var scrollView = Ti.UI.createScrollView({
       	backgroundColor:'green',
           bottom:120,
           showVerticalScrollIndicator: true,
         	showHorizontalScrollIndicator: true,
           layout: 'vertical'
       });
                   
       var view1 = Ti.UI.createView({
       	backgroundColor:'red',
       	width: 250,
       	height:250
       });
       
       var view2 = Ti.UI.createView({
       	backgroundColor:'blue',
       	width: 250,
       	height:250
       });
       
       scrollView.add(view1);
       scrollView.add(view2);
       
       scrollView.addEventListener('longpress', function(e) {
       	console.log('Long press on scrollview');
       });
       
       win.add(scrollView);
       win.open();
       
  2. Ashraf Abu 2016-04-05

    Updated code for testing to:-
       var win = Ti.UI.createWindow({ backgroundColor:'white'});
                   
       var scrollView = Ti.UI.createScrollView({
       	backgroundColor:'green',
           bottom:120,
           showVerticalScrollIndicator: true,
         	showHorizontalScrollIndicator: true,
           layout: 'vertical'
       });
                   
       var view1 = Ti.UI.createView({
       	backgroundColor:'red',
       	width: 250,
       	height:250
       });
        
       var view2 = Ti.UI.createView({
       	backgroundColor:'blue',
       	width: 250,
       	height:250
       });
        
       scrollView.add(view1);
       scrollView.add(view2);
        
       scrollView.addEventListener('longpress', function(e) {
       	console.log('Long press on scrollview:'+ e.x + '-'+e.y+'-'+e.type);
       });
        
       win.add(scrollView);
       win.open();
       
  3. Ashraf Abu 2016-04-05

    PR reviewed and merged.
  4. Lee Morris 2017-03-21

    Closing ticket as fixed.

JSON Source