Optional
helpURLIf set to a valid URL string, a help button which links to the URL will be visible in the prompt directing the user to web-based information about the action. Useful if prompting for options or configuration information that might require addition information to complete.
If true, a "Cancel" button will be included in the dialog. Defaults to true
. If the user selects the cancel button, the show()
method will return false
. If false
, no cancel button will be displayed and the user must select one of the button name options.
A longer message explaining the purpose of the dialog, if needed.
Short title which appears as a heading in the prompt window.
Add a button to the array of buttons to be displayed. All buttons should be created before calling show()
.
Optional
value: objectonly needed to associate a different value than will be displayed in the button. For example, if you call prompt.addButton("First Button", 1)
, after calling prompt.show()
if that button is pressed, the prompt.buttonPressed
will contain the number value 1
.
Optional
isDefault: booleanused to specify a single button which will be pinned to the bottom of the prompt and respond to cmd + return
as the default button. If only one button is added to a prompt, it is assumed to be the default.
Optional
isDestructive: booleanif true, present the button as a destructive action, typically a red button, in the intereface.
Optional
tintColor: tintColorOptionally override the default tint color of the button for the purpose of providing visual groupings. Tint colors are drawn from the current theme in use.
Add a date and/or time picker to the prompt, with the arguments as below. The fieldValues
entry for this will be a date object.
Identifier for the field. This will be used as the key in the fieldValues
dictionary to access the contents of the field after calling show()
.
User-friendly text label to place next to the field.
The initial date to selected for the field. Minimum and maximum values should be defined in options.
Optional
options: { A dictionary of options for configuring the text field.
Optional
maximumOptional
minimumOptional
minuteOptional
mode?: "date" | "time" | "dateAndTime"Add an information text label to the prompt.
Identifier for the field.
The text of the label.
Optional
options: { A dictionary of options for configuring the text field.
Optional
textAdd a picker to the prompt, with the arguments as below. Picker can contain multiple rows. The fieldValues
entry for this will be a array of selected index values object.
Identifier for the field. This will be used as the key in the fieldValues
dictionary to access the contents of the field after calling show()
.
User-friendly text label to place next to the field.
The values to display in the picker. Should be an array containing arrays of string values, each sub-array representing a column in the picker. Example two column picker: [["Item 1", "Item 2"],["Column 2 Item 1", "Column 2 Item 2"]]
Array of zero-based index values to set the initial selected row in each column.
Add a segmented control. Best used for selection between a small number of values. Returns a string value in fieldValues
.
Identifier for the field. This will be used as the key in the fieldValues
dictionary to access the contents of the field after calling show()
.
User-friendly text label to place next to the field.
The array of string values that will be available in the segmented control.
String values that should be initially selected when the prompt is displayed. Value should match value in the values
array.
Add a select control. Returns an array of string values in fieldValues
.
Identifier for the field. This will be used as the key in the fieldValues
dictionary to access the contents of the field after calling show()
.
User-friendly text label to place next to the field.
The array of string values that will be available to select.
Array of string values that should be initially selected when the prompt is displayed. All values in this array should match values in the values
array.
If false
, selecting a value will deselect all other values. If true
, the user may select multiple items.
Add an on/off toggle switch. The fieldValues
entry for this item will be a boolean indicating whether the switch was on.
Identifier for the field. This will be used as the key in the fieldValues
dictionary to access the contents of the field after calling show()
.
User-friendly text label to place next to the field.
indicate if the switch should be on or off when initially displayed.
Add a text input field to the prompt
Identifier for the field. This will be used as the key in the fieldValues
dictionary to access the contents of the field after calling show()
.
User-friendly text label to place next to the field.
The initial text contents for the field.
Optional
options: { A dictionary of options for configuring the text field.
Optional
autocapitalization?: capitalizationTypesOptional
autocorrect?: booleanShould system autocorrect be enabled in field, Default: true
Optional
keyboard?: keyboardTypesOptional
placeholder?: stringPlaceholder text to use when field is empty
Optional
wantsIf true, focus this field when prompt is displayed
Add a text input field to the prompt
Identifier for the field. This will be used as the key in the fieldValues
dictionary to access the contents of the field after calling show()
.
User-friendly text label to place next to the field.
The initial text contents for the field.
Optional
options: { A dictionary of options for configuring the text field.
Optional
autocapitalization?: capitalizationTypesOptional
autocorrect?: booleanShould system autocorrect be enabled in field, Default: true
Optional
height?: numberOptional
keyboard?: keyboardTypesOptional
wantsIf true, focus this field when prompt is displayed
After the show()
method is called, this property will contain the name of the button selected by the user.
After the show()
method is called, this property will contain values from any fields added to the prompt. The dictionary keys will be the names of the fields as passed in when they were created, and the value will be the current contents of that field. They type of data depends on the type of field.
Prompts allow the creation and display of custom dialogs to request information or confirmation from the user.
Example