Problem Description
When using optionDialog on android the click event returns depending on buttons vs options being clicked.
even.cancel is true when the cancel button is clicked, however it also gets set to true when the option with same index is clicked or an additional test for event.button needs to be performed. Really this should happen at the SDK level.
Steps to reproduce
1. Create a new mobile project (Ti Classic)
2. Add this to app.js:
var win = Ti.UI.createWindow({
backgroundColor: 'white',
exitOnClose: true,
});
var opts = {
title: 'Delete File?'
};
var isAndroid = Ti.Platform.osname == 'android';
if(isAndroid){
opts.options = ['Confirm', 'Cancel'];
opts.buttonNames = ['Help'];
//opts.Help = 0;
} else {
opts.options = ['Confirm', 'Help', 'Cancel'];
}
var dialog;
win.addEventListener('click',function(){
dialog = Ti.UI.createOptionDialog(opts);
dialog.show();
dialog.addEventListener('click', onSelectDialog);
});
function onSelectDialog(event){
if(isAndroid){
// event.button===true test is necessary
if(event.button === true /*&& event.Help === true*/) alert("ok");
}
//alert("ok") ;
}
win.open();
3. Run it in device.
PR https://github.com/appcelerator/titanium_mobile/pull/9476
FR Passed. Waiting for merge to get enabled.
PR Merged.
Changes are seen in SDK 7.0.0.v20171114203226. Need to wait for CR to be completed before closing.
Verified the fix in SDK 7.0.0.v20171116132144. Closing. Studio Ver: 5.0.0.201711161920 SDK Ver: 7.0.0.v20171116132144 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.3 Appc NPM: 4.2.11-2 Appc CLI: 7.0.0-master.27 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.9 Node Ver: 8.9.1 Java Ver: 1.8.0_101 Devices: ⇨ google Pixel --- Android 7.1.1 ⇨ google Nexus 5 --- Android 6.0.1