[AC-1086] Click on table view section doesn't produce click event
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-07-24T08:33:45.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | Ivan Skugor |
Assignee | Shuo Liang |
Created | 2014-07-10T15:00:23.000+0000 |
Updated | 2016-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.
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
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.
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.