mobicontrol.message.ConfirmationDialog

This class represents a confirmation dialog.

Users can interact with a confirmation dialog either by clicking a button or by dismissing the dialog.

ConfirmationDialog

Since:
  • Version 1.1 (API level 2)

Methods

async show() → {number}

Display the dialog.

Every time show() is called, a new dialog opens, with a unique ID.

Returns:
number - The unique ID of the dialog that opens.
Since:
  • Version 1.1 (API level 2)

withButtons(button0Label, button1Labelopt, button2Labelopt) → {mobicontrol.message.ConfirmationDialog}

Set the custom buttons for the dialog.
Parameters:
Name Type Attributes Description
button0Label string The first button's label (cannot be an empty string).
button1Label string <optional>
The second button's label (cannot be an empty string).
button2Label string <optional>
The third button's label (cannot be an empty string).
Returns:
mobicontrol.message.ConfirmationDialog - This dialog.
Since:
  • Version 1.1 (API level 2)
Example
var buttonLabels = ['Red', 'Green', 'Blue'];
mobicontrol.message.createInfoDialog('Choose the colour.')
    .withButtons(buttonLabels[0], buttonLabels[1], buttonLabels[2])
    .withCallback(onConfirm).show();

function onConfirm(result) {
    if (result.buttonIndex != null) {
        mobicontrol.log.info('The ' + buttonLabels[result.buttonIndex] + ' button was clicked.');
    }
}

withCallback(callbackFunction) → {mobicontrol.message.ConfirmationDialog}

Set a callback function for the dialog.

The callback function is called when the dialog is closed. For example, when the dialog times out, or a button is clicked, or the dialog is dismissed.

Parameters:
Name Type Description
callbackFunction mobicontrol.message.ConfirmationDialog.ConfirmationDialogCallback The callback function for this dialog.
Returns:
mobicontrol.message.ConfirmationDialog - This dialog.
Since:
  • Version 1.1 (API level 2)
Example
mobicontrol.message.createYesNoDialog('Would you like to reboot now?')
    .withCallback(onConfirm).show();

function onConfirm(result) {
    if (result.isYesButton) {
        mobicontrol.log.info('The Yes button was clicked');
    } else if (result.isNoButton) {
        mobicontrol.log.info('The No button was clicked');
    } else if (result.isDismissed) {
        mobicontrol.log.info('The dialog was dismissed');
    }
}

withErrorIcon() → {mobicontrol.message.ConfirmationDialog}

Set the error icon for the dialog.
Returns:
mobicontrol.message.ConfirmationDialog - This dialog.
Since:
  • Version 1.1 (API level 2)
Example
mobicontrol.message.createInfoDialog('Error occurred!')
    .withErrorIcon().show();

withInfoIcon() → {mobicontrol.message.ConfirmationDialog}

Set the info icon for the dialog.
Returns:
mobicontrol.message.ConfirmationDialog - This dialog.
Since:
  • Version 1.1 (API level 2)

withNotification() → {mobicontrol.message.ConfirmationDialog}

Set notification for the dialog.

Make the dialog create a notification when shown.

Returns:
mobicontrol.message.ConfirmationDialog - This dialog.
Since:
  • Version 1.1 (API level 2)
Example
mobicontrol.message.createInfoDialog('This dialog has a notification.')
    .withNotification().show();

withQuestionIcon() → {mobicontrol.message.ConfirmationDialog}

Set the question icon for the dialog.
Returns:
mobicontrol.message.ConfirmationDialog - This dialog.
Since:
  • Version 1.1 (API level 2)

withTimer(timeoutInMillis) → {mobicontrol.message.ConfirmationDialog}

Set the timeout for the dialog.

The dialog is dismissed automatically when the timeout expires.

Parameters:
Name Type Description
timeoutInMillis number The timeout in milliseconds. Must be greater than zero.
Returns:
mobicontrol.message.ConfirmationDialog - This dialog.
Since:
  • Version 1.1 (API level 2)
Example
mobicontrol.message.createInfoDialog('This dialog will be dismissed in 5 seconds.')
    .withTimer(5000).show();

withTitle(title) → {mobicontrol.message.ConfirmationDialog}

Set the title for the dialog.
Parameters:
Name Type Description
title string The title for this dialog.
Returns:
mobicontrol.message.ConfirmationDialog - This dialog.
Since:
  • Version 1.1 (API level 2)
Example
mobicontrol.message.createInfoDialog('This dialog has a non-default title.')
    .withTitle('Test title').show();

withWarnIcon() → {mobicontrol.message.ConfirmationDialog}

Set the warning icon for the dialog.
Returns:
mobicontrol.message.ConfirmationDialog - This dialog.
Since:
  • Version 1.1 (API level 2)

Type Definitions

ConfirmationDialogCallback(result)

Callback function for mobicontrol.message.ConfirmationDialog.withCallback.
Parameters:
Name Type Description
result object Result of the dialog interaction.
Properties
Name Type Description
isYesButton boolean true if the Yes button was clicked.

This property is true if the dialog has the standard Yes button, and this button was clicked; false otherwise.
Note: If the dialog has custom buttons set by withButtons, and the clicked button is labeled 'Yes', this property is false.

isNoButton boolean true if the No button was clicked.

This property is true if the dialog has the standard No button, and this button was clicked; false otherwise.
Note: If the dialog has custom buttons set by withButtons, and the clicked button is labeled 'No', this property is false.

isCancelButton boolean true if the Cancel button was clicked.

This property is true if the dialog has the standard Cancel button, and this button was clicked; false otherwise.
Note: If the dialog has custom buttons set by withButtons, and the clicked button is labeled 'Cancel', this property is false.

isOkButton boolean true if the OK button was clicked.

This property is true if the dialog has the standard OK button, and this button was clicked; false otherwise.
Note: If the dialog has custom buttons set by withButtons, and the clicked button is labeled 'OK', this property is false.

buttonIndex number The index of the button that was pressed.

This property is null if no button was pressed.

isDismissed boolean true if the dialog was dismissed, false otherwise.

A dialog is considered dismissed if it was closed as a result of event other than a dialog's button click. For example, by expiry of its timer or by a click on the Back button in the navigation bar.

isTimedOut boolean true if the dialog was dismissed due to a timeout, false otherwise.
dialogId number The unique ID of the dialog.
buttonLabel string The label of the clicked button.

If the dialog has no custom buttons, this is the English label in all caps.

Since:
  • Version 1.1 (API level 2)