Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19526] ListView - setting "allowsSelection" to "false" disables "itemclick" event

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionWon't Fix
Resolution Date2019-12-09T23:24:27.000+0000
Affected Version/sRelease 4.1.1
Fix Version/sn/a
Componentsn/a
LabelsTCSupportTriage, engTriage
ReporterIvan Skugor
AssigneeUnknown
Created2014-09-09T10:06:51.000+0000
Updated2019-12-09T23:24:27.000+0000

Description

When "allowsSelection" is set to "false" (which means, rows should not show color which means they are selected), "itemclick" event is not fired. I think that is wrong, selection is one thing, clicking on whole list view is whole other thing and it should not be affected by "allowsSelection" property. To see this issue, run this code:
var win = Ti.UI.createWindow({backgroundColor: 'white', top: 20});
var listView = Ti.UI.createListView({
	allowsSelection: false
});
var sections = [];

var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits'});
var fruitDataSet = [
    {properties: { title: 'Apple'}},
    {properties: { title: 'Banana'}},
];
fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);

var vegSection = Ti.UI.createListSection({ headerTitle: 'Vegetables'});
var vegDataSet = [
    {properties: { title: 'Carrots'}},
    {properties: { title: 'Potatoes'}},
];
vegSection.setItems(vegDataSet);
sections.push(vegSection);

listView.setSections(sections);

listView.addEventListener('itemclick', function(e) {
	alert(e);
});

win.add(listView);
win.open();
Click on some row - you should not see alert dialog (and IMO you should).

Comments

  1. Shannon Hicks 2015-01-22

    While the ticket title is true, the solution is to have allowsSelection=true and set
    selectionStyle:Ti.UI.iPhone.ListViewCellSelectionStyle.NONE
    for every ListViewItem.
  2. Ivan Skugor 2015-01-23

    Ahh, that workaround is hard to notice, thanks for pointing it out!
  3. Alan Hutton 2019-12-09

    Closing as "Won't fix. when setting *allowsSelection* to *false* itemclick events will not fire. This is by design.

JSON Source