Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20191] The e.source of a table click event is supposed to return the table row but instead it returns the table view

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-01-11T14:15:20.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.3.0
ComponentsWindows
Labelsqe-5.3.0
ReporterKai Lu
AssigneeKota Iguchi
Created2016-01-04T13:55:04.000+0000
Updated2016-04-26T22:05:57.000+0000

Description

The e.source of a table click event is supposed to return the table row but instead it returns the table view

Comments

  1. Kota Iguchi 2016-01-05

    Confirmed that TableView click event actually returns table row as source on iOS.
       var win = Ti.UI.createWindow();
       var tableData = [ {title: 'Apples'}, {title: 'Bananas'}, {title: 'Carrots'}, {title: 'Potatoes'} ];
       var table = Ti.UI.createTableView({
         data: tableData
       });
       table.addEventListener('click', function(e) {
         Ti.API.info(e.source == table);
         Ti.API.info(e.source.toString());
       });
       win.add(table);
       win.open();
       
    But is this really how it's supposed to work? I thought it should return true "event source" in theory.
       object.addEventListener('xxx', function(e) {
           THIS_SHOULD_BE_TRUE(e.source == object);
       });
       
  2. Kai Lu 2016-01-05

    Hi Kota, I think the source of a click event should be the top touchable source in the view hierarchy where the user has clicked on. The source can be the touchEnabled subview of the object that you have the listener on. So, if you clicked on the table, the row or a label on the row is the top view and hence the source of the click event. That's exactly what user wants to listen to. If I want to have the table as the source of the click event then I should make all its subviews as touchEnabled = false. Regards, Kai
  3. Kota Iguchi 2016-01-11

    https://github.com/appcelerator/titanium_mobile_windows/pull/529
  4. Harry Bryant 2016-04-26

    Verified as fixed, Tested demo code provided in PR and all return true:
       var win = Ti.UI.createWindow();
       var tableData = [{ title: 'Apples' }, { title: 'Bananas' }, { title: 'Carrots' }, { title: 'Potatoes' }];
       var table = Ti.UI.createTableView({
           data: tableData
       });
       table.addEventListener('click', function (e) {
           Ti.API.info(e.source != table); // should be true
           Ti.API.info(e.source == e.row); // should be true
           Ti.API.info(e.source.title == e.row.title); // should be true
       });
       win.add(table);
       win.open();
       
    Tested on: Windows 10 Pro Windows Phone 10.0 & 8.1 (Microsoft Lumia 640 LTE) Appc Studio: 4.6.0.201604081249 Ti SDK: 5.3.0.v20160421080259 Appc NPM: 4.2.5-3 Appc Core: 5.3.0-34 Node: v4.4.2 *Closing Ticket.*

JSON Source