-
Notifications
You must be signed in to change notification settings - Fork 29
PKUI.MESSAGE.Confirm
(part of PKUI.MESSAGE)
Return Type: message
Parameters: title, text, buttons (all string), dismissFunction ( function )
Creates a confirmation message box with the desired title, text, and buttons. When a button is pressed or the message box is dismissed, the dismissFunction
is called with the button index (or -1
if dismissed without a button press).
The title
and text
can be regular text or have HTML embedded. If HTML is used, be sure to properly end any tags.
buttons
is a pipe (|
) delimited string that defines each button. Each button can also contain modifiers at the end of the button's text that changes how the button is classed. If there are two buttons or fewer, the buttons will be inline with each other -- if there are three or more buttons, they will be displayed in a list.
The button modifiers are as follows:
Modifier Class Example
* destructive Delete Item*
> go Open in Browser>
< cancel Cancel<
_ wideButton This is a wide button_
Modifiers are removed from their button's text. If the button needs to display a modifier character at the end of the button, there must be a space after the modifier character, such as Delete*
. In this case, the asterisk will render as part of the button's text.
Note: Not every platform will display a button that has a modifier differently. As of v0.2, only the iOS platform renders the destructive
, go
, and cancel
buttons with different button styles.
Example:
var mbox = new PKUI.MESSAGE.Confirm (
"Confirmation",
"Are you sure you want to delete the file?",
"Delete*|Cancel<",
function ( buttonIndex )
{
if (buttonIndex === 0) { deleteTheFile(); }
}
);
mbox.show();
var mbox = new PKUI.MESSAGE.Confirm (
"Select an Option",
"Select an option from the list below.",
"Option 1|Option 2|Option 3|Cancel<",
function ( buttonIndex )
{
if (buttonIndex == 3 || buttonIndex < 0) { return; }
// do something with the option selected
}
);
mbox.show();
- Only iOS (as of v0.2) renders button modifiers differently. Destructive buttons are rendered with a red background, Action buttons (classed
go
) are rendered with a green background, and Cancel buttons are rendered with a dark grey background. - The message box does not appear until explicitly shown via the show method.
- Once the message box is shown, it does not disappear until it is explicitly hidden, a button is tapped, or a physical back button event occurs (assuming the back button is intended to be caught).
- show
- hide
- backButtonPressed
- dismiss (buttonIndex)
0.1 Introduced
0.2 Docs Valid