[TIMOB-20374] Android: Longpress event on ScrollView doesn't fire
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-04-05T04:27:26.000+0000 |
| Affected Version/s | Release 5.1.2 |
| Fix Version/s | n/a |
| Components | Android |
| Labels | Android, ScrollView, longpress |
| Reporter | Thomas Neerup |
| Assignee | Srikanth Sombhatla |
| Created | 2016-02-09T06:58:15.000+0000 |
| Updated | 2017-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();
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();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();PR reviewed and merged.
Closing ticket as fixed.