TextPromptDialog
- 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.TextPromptDialog}
-
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.TextPromptDialog - This dialog.- Since:
- Version 1.1 (API level 2)
Example
mobicontrol.message.createTextPromptDialog('How many balloons do you wish to order?') .withButtons('Red', 'Green', 'Blue') .withCallback(onConfirm).show(); function onConfirm(result) { if (result.buttonLabel != null && isNumeric(result.inputText)) { mobicontrol.log.info('Ordered ' + result.inputText + ' ' + result.buttonLabel + ' balloons.'); } } function isNumeric(num) { return !isNaN(num); }
-
withCallback(callbackFunction) → {mobicontrol.message.TextPromptDialog}
-
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.TextPromptDialog.ConfirmationDialogCallback The callback function for this dialog. Returns:
mobicontrol.message.TextPromptDialog - This dialog.- Since:
- Version 1.1 (API level 2)
Example
mobicontrol.message.createTextPromptDialog('What is the account number?') .withCallback(onConfirm).show(); function onConfirm(result) { mobicontrol.log.info(result.inputText); }
-
withDefaultText(defaultText) → {mobicontrol.message.TextPromptDialog}
-
Set the default text for the text box.
Parameters:
Name Type Description defaultText
string The default text to be shown in the text box. Returns:
mobicontrol.message.TextPromptDialog - This dialog.- Since:
- Version 1.1 (API level 2)
Example
mobicontrol.message.createTextPromptDialog('What is the account number?') .withDefaultText("74").show();
-
withErrorIcon() → {mobicontrol.message.TextPromptDialog}
-
Set the error icon for the dialog.
Returns:
mobicontrol.message.TextPromptDialog - This dialog.- Since:
- Version 1.1 (API level 2)
-
withInfoIcon() → {mobicontrol.message.TextPromptDialog}
-
Set the info icon for the dialog.
Returns:
mobicontrol.message.TextPromptDialog - This dialog.- Since:
- Version 1.1 (API level 2)
-
withNotification() → {mobicontrol.message.TextPromptDialog}
-
Set notification for the dialog. Make the dialog create a notification when shown.
Returns:
mobicontrol.message.TextPromptDialog - This dialog.- Since:
- Version 1.1 (API level 2)
-
withQuestionIcon() → {mobicontrol.message.TextPromptDialog}
-
Set the question icon for the dialog.
Returns:
mobicontrol.message.TextPromptDialog - This dialog.- Since:
- Version 1.1 (API level 2)
-
withTimer(timeoutInMillis) → {mobicontrol.message.TextPromptDialog}
-
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.TextPromptDialog - This dialog.- Since:
- Version 1.1 (API level 2)
-
withTitle(title) → {mobicontrol.message.TextPromptDialog}
-
Set the title for the dialog.
Parameters:
Name Type Description title
string The title for this dialog. Returns:
mobicontrol.message.TextPromptDialog - This dialog.- Since:
- Version 1.1 (API level 2)
-
withWarnIcon() → {mobicontrol.message.TextPromptDialog}
-
Set the warning icon for the dialog.
Returns:
mobicontrol.message.TextPromptDialog - This dialog.- Since:
- Version 1.1 (API level 2)
Type Definitions
-
ConfirmationDialogCallback(result)
-
Callback function for mobicontrol.message.TextPromptDialog.withCallback.
Parameters:
Name Type Description result
object Result of the dialog interaction. Properties
Name Type Description inputText
string The text entered by the user. This property is null
if the dialog was dismissed.isOkButton
boolean true
if the OK button was clicked. This property istrue
if the dialog has the standard OK button, and this button was clicked;false
otherwise.
Note: If the dialog has custom buttons set bywithButtons
, and the clicked button is labeled 'OK', this property isfalse
.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)