[AC-4804] "click" events on TableViewRow do not fire on TableViewRow with Ti.UI.Switch
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-02-20T19:26:59.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | android |
Reporter | grazianogrespan |
Assignee | Shak Hossain |
Created | 2017-02-19T17:08:30.000+0000 |
Updated | 2017-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();
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.
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.