Content-Length: 463859 | pFad | http://github.com/NativeScript/NativeScript/commit/3cf3dccdfca2dc4c351bff0f1e91aa31f3075fb4

4E Merge pull request #1086 from NathanaelA/DialogBox_Fixes · NativeScript/NativeScript@3cf3dcc · GitHub
Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3cf3dcc

Browse files
author
Vladimir Enchev
committedNov 17, 2015
Merge pull request #1086 from NathanaelA/DialogBox_Fixes
This will now allow the dialog to call the resolve function when cancelled by clicking outside.
2 parents 2026526 + 77f3008 commit 3cf3dcc

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed
 

‎ui/dialogs/dialogs.android.ts

+27
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ function createAlertDialog(options?: dialogs.DialogOptions): android.app.AlertDi
1313
var alert = new android.app.AlertDialog.Builder(appmodule.android.foregroundActivity);
1414
alert.setTitle(options && types.isString(options.title) ? options.title : "");
1515
alert.setMessage(options && types.isString(options.message) ? options.message : "");
16+
if (options && options.cancelable === false) {
17+
alert.setCancelable(false);
18+
}
1619
return alert;
1720
}
1821

@@ -72,6 +75,11 @@ function addButtonsToAlertDialog(alert: android.app.AlertDialog.Builder, options
7275
}
7376
}));
7477
}
78+
alert.setOnDismissListener(new android.content.DialogInterface.OnDismissListener({
79+
onDismiss: function() {
80+
callback(false);
81+
}
82+
}));
7583
}
7684

7785
export function alert(arg: any): Promise<void> {
@@ -87,6 +95,11 @@ export function alert(arg: any): Promise<void> {
8795
resolve();
8896
}
8997
}));
98+
alert.setOnDismissListener(new android.content.DialogInterface.OnDismissListener({
99+
onDismiss: function() {
100+
resolve();
101+
}
102+
}));
90103

91104
showDialog(alert);
92105

@@ -262,6 +275,9 @@ export function action(arg: any): Promise<string> {
262275
var alert = new android.app.AlertDialog.Builder(activity);
263276
var message = options && types.isString(options.message) ? options.message : "";
264277
var title = options && types.isString(options.title) ? options.title : "";
278+
if (options && options.cancelable === false) {
279+
alert.setCancelable(false);
280+
}
265281

266282
if (title) {
267283
alert.setTitle(title);
@@ -289,6 +305,17 @@ export function action(arg: any): Promise<string> {
289305
}
290306
}));
291307
}
308+
309+
alert.setOnDismissListener(new android.content.DialogInterface.OnDismissListener({
310+
onDismiss: function() {
311+
if (types.isString(options.cancelButtonText)) {
312+
resolve(options.cancelButtonText);
313+
} else {
314+
resolve("");
315+
}
316+
}
317+
}));
318+
292319
showDialog(alert);
293320

294321
} catch (ex) {

‎ui/dialogs/dialogs.d.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,21 @@ declare module "ui/dialogs" {
8181
* @param options The options for the dialog box.
8282
*/
8383
export function action(options: ActionOptions): Promise<string>;
84+
85+
/**
86+
* Provides options for the dialog.
87+
*/
88+
export interface CancelableOptions {
89+
/**
90+
* [Android only] Gets or sets if the dialog can be canceled by taping outside of the dialog.
91+
*/
92+
cancelable?: boolean;
93+
}
8494

8595
/**
8696
* Provides options for the dialog.
8797
*/
88-
export interface ActionOptions {
98+
export interface ActionOptions extends CancelableOptions {
8999
/**
90100
* Gets or sets the dialog title.
91101
*/
@@ -110,7 +120,7 @@ declare module "ui/dialogs" {
110120
/**
111121
* Provides options for the dialog.
112122
*/
113-
export interface DialogOptions {
123+
export interface DialogOptions extends CancelableOptions {
114124
/**
115125
* Gets or sets the dialog title.
116126
*/
@@ -120,6 +130,7 @@ declare module "ui/dialogs" {
120130
* Gets or sets the dialog message.
121131
*/
122132
message?: string;
133+
123134
}
124135

125136
/**

0 commit comments

Comments
 (0)
Failed to load comments.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/NativeScript/commit/3cf3dccdfca2dc4c351bff0f1e91aa31f3075fb4

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy