Titanium Mobile
  1. Titanium Mobile
  2. TIMOB-11691

iOS: Click event on button in TableViewRow doesn't include row property

    Details

      Description

      When creating a custom row that includes a button as a child, and adding a click event listener to the table, the "row" property is not being added to the click event as it bubbles up.

      For some reason it seems to be added for other view types, but not for buttons.

      Test case:

      Ti.UI.setBackgroundColor('#000');
      
      var win = Ti.UI.createWindow({
      	title : 'TableView Event Bubbling',
      });
      
      function makeRow() {
      	var row= Ti.UI.createTableViewRow({
      		backgroundColor: 'white',
      		className: 'myRowClass'
      	});
      	row.add(Ti.UI.createButton({
      		title: "My Button",
      		left: 0,
      		top: 50
      	}));
      	row.add(Ti.UI.createLabel({
      		text: Math.random().toString(36).substring(7),
      		left: 10,
      		right: 10,
      		textAlign: Ti.UI.TEXT_ALIGN_CENTER,
      		top: 0,
      		touchEnabled: true
      	}))
      	row.add(Ti.UI.createImageView({
      		image: 'KS_nav_ui.png',
      		right: 0,
      		top: 50,
      		touchEnabled: true
      	}));
      	return row;
      }
      var data = [];
      for(var i = 0; i < 100; i++) {
      	data.push(makeRow());
      }
      
      var tbl = Ti.UI.createTableView({
      	data: data
      });
      tbl.addEventListener('click', function(e) {
      	Ti.API.info("e.row =" + e.row + ", e.source = " + e.source);
      });
      win.add(tbl);
      win.open();
      

      On 2.1.3, if I click around, I get:

      [INFO] TableViewRows/1.0 (2.1.3.GA.15997d0)
      [INFO] e.row =[object TiUITableViewRow], e.source = [object TiUIButton]
      [INFO] e.row =[object TiUITableViewRow], e.source = [object TiUITableViewRow]
      [INFO] e.row =[object TiUITableViewRow], e.source = [object TiUIImageView]
      [INFO] e.row =[object TiUITableViewRow], e.source = [object TiUILabel]
      

      But on 2.1.4, I get:

      [INFO] TableViewRows/1.0 (3.1.0.v20121106112514.971021f)
      [ERROR] TableViewRow structures for className myRowClass does not match
      [ERROR] TableViewRow structures for className myRowClass does not match
      [ERROR] TableViewRow structures for className myRowClass does not match
      [ERROR] TableViewRow structures for className myRowClass does not match
      [INFO] e.row =undefined, e.source = [object TiUIButton]
      [INFO] e.row =[object TiUITableViewRow], e.source = [object TiUITableViewRow]
      [INFO] e.row =[object TiUITableViewRow], e.source = [object TiUIImageView]
      [INFO] e.row =[object TiUITableViewRow], e.source = [object TiUILabel]
      

      So 3.0/3.1 logs an error "structures for className does not match", and the button click doesn't have a row property.

        Activity

        Show
        Vishal Duggal added a comment - Pull pending https://github.com/appcelerator/titanium_mobile/pull/3455
        Show
        Vishal Duggal added a comment - Backport PR https://github.com/appcelerator/titanium_mobile/pull/3461
        Hide
        Anshu Mittal added a comment -

        Tested with:
        SDK:3.1.0.v20130114171802
        Studio:3.0.1.201212181159
        Device: iPhone3GS(v5.0.1)

        Show
        Anshu Mittal added a comment - Tested with: SDK:3.1.0.v20130114171802 Studio:3.0.1.201212181159 Device: iPhone3GS(v5.0.1)

          People

          • Assignee:
            Vishal Duggal
            Reporter:
            Arthur Evans
          • Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: