Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11691] iOS: Click event on button in TableViewRow doesn't include row property

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-11-21T22:45:13.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sRelease 3.1.0, 2012 Sprint 24, 2012 Sprint 24 API
ComponentsiOS
Labelsapi, module_tableviewrow, qe-testadded, regression
ReporterArthur Evans
AssigneeVishal Duggal
Created2012-11-07T22:35:54.000+0000
Updated2013-08-27T10:31:16.000+0000

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.

Comments

  1. Vishal Duggal 2012-11-21

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/3455
  2. Vishal Duggal 2012-11-21

    Backport PR https://github.com/appcelerator/titanium_mobile/pull/3461
  3. Anshu Mittal 2013-01-18

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

JSON Source