Problem
When the cancel button of an [Titanium.UI.AlertDialog](
http://docs.appcelerator.com/titanium/2.0/index.html#!/api/Titanium.UI.AlertDialog-property-cancel) is clicked, the cancel property on Android returns
true
whereas iOS returns the [cancel](Titanium.UI.AlertDialog.cancel) property, which will typically not change regardless of the button clicked.
As the Android behavior reduces developer code marginally, suggest that iOS be brought in line with it.
As the AlertDialog code is so closely related to OptionDialog, OptionDialog should be checked for this issue also.
Test case
Ti.UI.setBackgroundColor('white');
var win = Ti.UI.createWindow({
title: 'Click window to test',
backgroundColor: 'white',
exitOnClose: true,
fullscreen: false
});
win.addEventListener('click', function(e){
var dialog = Ti.UI.createAlertDialog({
cancel: 1,
buttonNames: ['Confirm', 'Cancel', 'Help'],
message: 'Would you like to delete the file?',
title: 'Delete'
});
dialog.addEventListener('click', function(e){
if (e.index === e.source.cancel){
Ti.API.info('The cancel button was clicked');
}
Ti.API.info('e.cancel: ' + e.cancel);
Ti.API.info('e.source.cancel: ' + e.source.cancel);
Ti.API.info('e.index: ' + e.index);
});
dialog.show();
});
win.open();
Closing ticket due to lack of activity and time passed.