[TIMOB-8411] iOS: Ti.UI.TableView swipe event e.source doesn't return the correct object
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2012-04-03T14:14:46.000+0000 |
Affected Version/s | Release 1.8.2 |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | Junaid Younus |
Assignee | Vishal Duggal |
Created | 2012-03-29T09:21:12.000+0000 |
Updated | 2017-03-23T21:37:47.000+0000 |
Description
*Code*
var win = Ti.UI.createWindow({
backgroundColor: 'white'
});
var table = Ti.UI.createTableView();
var data = [];
for (var i = 0; i < 20; i++)
{
var row = Ti.UI.createTableViewRow({
myRowID: i
});
var label = Ti.UI.createLabel({
text: i,
left: 0,
width: 'auto'
});
row.add(label);
data.push(row);
}
table.setData(data);
table.addEventListener('swipe', function(e)
{
var row = e.source;
if (!row)
return;
Ti.API.info('Row swiped: ' + row);
Ti.API.info('Row ID : ' + row.myRowID);
});
win.add(table);
win.open();
*Expected behavior*
When you swipe on a row, e.source should return the correct Ti.UI.TableViewRow object and the ID of the row should be printed out in the console.
*Actual behavior*
Every time you swipe on a row, e.source actually returns the Ti.UI.TableView object itself, not the specific row.
*Notes*
-If you change 'swipe' to 'click' event, you will see that it prints out the correct values and has the correct behavior.
-Only tested on iOS 5 simulator, with TiSDK 1.8.2
Swipe is a gesture and not a touch event like click. Gesture recognizers are not registered unless you add an event handler. Since the swipe event handler was added to the table, the table is the only one generating the swipe events. Gesture List singletap doubletap twofingertap swipe pinch longpress
Vishal, so how would do what the customer is trying to do? Ti.UI.TableViewRow doesn't register any gestures, according to our documentation.
Ok my mistake, gesture recognizers are always registered. Anyways like click events the swipe gesture will report the actual view on which the gesture occurred. Try this code. Swiping should give you the correct row id.
Provided JS workaround
Marking this bug invalid as the functionality works as expected. We have just provided information on how to make use of this functionality.
Surely there should be no need for the enabledWrapperView? Why doesn't the row respond as the source of a table swipe event, if all child views have touchEnabled set to false?
Closing ticket as invalid with reference to the previous comments.