Titanium JIRA Archive
Appcelerator Community (AC)

[AC-4804] "click" events on TableViewRow do not fire on TableViewRow with Ti.UI.Switch

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2017-02-20T19:26:59.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsandroid
Reportergrazianogrespan
AssigneeShak Hossain
Created2017-02-19T17:08:30.000+0000
Updated2017-02-20T19:26:59.000+0000

Description

If I add a "click" event to a TableViewRow with a Ti.UI.Switch, the event does not fire if the row is pressed. This behaviour affects only Android O.S , if you try to run the code below on iOS you will not see this bug.
var win = Ti.UI.createWindow();

var rowWithSwitch = Ti.UI.createTableViewRow({height:100});
var uiSwitch = Ti.UI.createSwitch();

rowWithSwitch.add(uiSwitch);
// the alert does not appear if you press the row
rowWithSwitch.addEventListener("click",function(){ alert(" Row clicked ");});


var rowWithoutSwitch = Ti.UI.createTableViewRow({height:100});
// the alert appears correctly
rowWithoutSwitch.addEventListener("click",function(){ alert(" Row clicked ");});


var tableView = Ti.UI.createTableView({
	data: [rowWithSwitch,rowWithoutSwitch]
});

win.add(tableView);

win.open();

Comments

  1. grazianogrespan 2017-02-19

    I have just found that if I put "focusable" property to "false" on Ti.UI.Switch click events fire correctly. I don't know if this is an hack or the right purpose of focusable property. Anyway, maybe, it should be written on the doc.
  2. Sharif AbuDarda 2017-02-20

    Hello, It's documented. http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.Switch-property-focusable " Whether view should be focusable while navigating with the trackball.". Since you are adding switch in tableviewrow and you are adding eventlistener in row you should add this to work both. And specifically for Android. You can turn off the listener for row by setting this false and work only with switch. Thanks.

JSON Source