Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1086] Click on table view section doesn't produce click event

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2014-07-24T08:33:45.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterIvan Skugor
AssigneeShuo Liang
Created2014-07-10T15:00:23.000+0000
Updated2016-03-08T07:37:26.000+0000

Description

Hello. Seems like if table view section is clicked, "click" event is not being fired (if table view row is clicked, it works fine). To see this issue, run this code:
var win = Ti.UI.createWindow({
	backgroundColor: '#333',
	top: 20
});

var table = Ti.UI.createTableView();

function createSection(name) {
	var label = Ti.UI.createLabel({
		text: name
	});
	var wrapper = Ti.UI.createView({
		height: 40,
		backgroundColor: '#fff',
		opacity: 0.9
	});
	wrapper.add(label);

	var section = Ti.UI.createTableViewSection({
		headerView: wrapper
	});

	return section;

}

function createRow() {
	var row = Ti.UI.createTableViewRow({
		height: 100,
		backgroundColor: '#c96'
	});

	var label = Ti.UI.createLabel({
		text: 'Testing ...'
	});

	row.add(label);

	return row;
}

var sections = [], section;
for (var i = 0; i < 10; i++) {
	section = createSection('Section ' + i);
	section.add(createRow());
	sections.push(section);
}

table.setData(sections);

table.addEventListener('click', function() {
	alert('on click');
});

win.add(table);

win.open();
Not that this should work since "click" event is added to table view and it seems this kind of use case produces events on native application.

Comments

  1. Shuo Liang 2014-07-24

    Hi, You had added 'click' event to the table view, so this event will only fired when a table row is clicked like doc mentioned. Ref: http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TableView-event-click Regards, Shuo
  2. Ivan Skugor 2014-07-24

    Hello. I am aware of that, but could that be a bug? TableView view contains TableViewSection which contains TableViewRow. So, they are in parent - child relationship. Event should propagate from child elements to parent - right? So, in my opinion, even TableViewSection should produce TableView event since TableViewSection is it's child.
  3. Shuo Liang 2014-07-24

    no, I don't think so. Based on your code, the "section number" area is a header view for each row, it should not be triggered. If you want add some events to header view, you should add it into specific view you want.

JSON Source