[TIMOB-23486] Android: Add an option to handle AlertDialog box outside touch.
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-06-14T20:51:52.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 6.0.0 |
Components | Android |
Labels | AlertDalog |
Reporter | Jebun Naher |
Assignee | Ashraf Abu |
Created | 2016-06-09T09:17:54.000+0000 |
Updated | 2016-08-12T01:00:40.000+0000 |
Description
*Overview:*
In android, when I click outside the AlertDialog, AlertDialog box will close. I need to close AlertDialog only when I click on cancel button in AlertDialog.
[https://developer.android.com/reference/android/app/Dialog.html#setCanceledOnTouchOutside(boolean)]
steps to reproduce
1. Just create a sample project 2. Paste the following code 3. Run it on device and click the button 4. Then touch outside the dialog 5. It dismisses, the customer wants to prevent thatTest Code
var win = Ti.UI.createWindow({
});
var alertDialog = Ti.UI.createButton({
title : 'ShowDialog',
height : Ti.UI.SIZE,
width : Ti.UI.SIZE,
});
// Listen for click events.
alertDialog.addEventListener('click', function() {
var dialog = Ti.UI.createAlertDialog({
message : 'The file has been deleted',
cancel : 1,
buttonNames : ['Confirm', 'Cancel'],
message : 'Would you like to delete the file?',
title : 'Delete'
});
dialog.show();
});
// Add to the parent view.
win.add(alertDialog);
win.open();
Thanks
not sure if this is native behavior. [~msamah]?
[~cng] This is an improvement ticket that requests for a property to be exposed to allow for that behaviour. It's something that should be doable.
[~jnaher] Just to make this ticket complete, could you have a sample code for the AlertDialog included in this ticket?
Master PR: https://github.com/appcelerator/titanium_mobile/pull/8053
Verified the implementation. The
canceledOnTouchOutside
property works as expected. Closing. Environment: Appc Studio : 4.7.0.201607250649 Ti SDK : 6.0.0.v20160810073036 Ti CLI : 5.0.9 Alloy : 1.9.1 MAC El Capitan : 10.11.6 Appc NPM : 4.2.7 Appc CLI : 6.0.0-24 Node: 4.4.4 Nexus 5 - Android 6.0.1