Page tree
Skip to end of metadata
Go to start of metadata
messageBox(stringOrConfigTable)

Description

Function to open a modal message box. If the argument is a single string, the text will be displayed in the default message box. Alternatively, you can customize the message box by using a configuration table, e.g., if you want to display the text with a warning icon.

Available in: Controller.

Arguments

stringOrConfigTableThe message as a string or the configuration table that customizes the message box.string or table

Configuration Table

The message box can be configured by creating a table with the following fields:

.typeThe type of the message box defines which icon will be displayed. It can be determined via names or indices. The default is MessageBoxType.information.enum or number
.textThe text that will be displayed.string
.button1This button is always displayed. The default string is "OK".string, optional
.button2This button will only be displayed if you assign a string to this field.string, optional
.button3This button will only be displayed if you assign a string to this field.string, optional

Return Values

Returns the result of the message box, i.e., which action closed the message box, as a number.

Message Box Types

Enumerator to identify the types of the message box. The type of the message box also defines which icon will be displayed.

IndexName
1MessageBoxType.warning
2MessageBoxType.question
3MessageBoxType.information

Message Box Results

Enumerator to identify the results of the message box.

IndexName
1MessageBoxResult.escape
2MessageBoxResult.button1
3MessageBoxResult.button2
4MessageBoxResult.button3

Example

-- customized message box
myMessage = {}
 
myMessage.type = MessageBoxType.question
myMessage.text = "Click the button with the correct answer!\n1 + 1 = ?"
myMessage.button1 = "1"
myMessage.button2 = "2"
myMessage.button3 = "3"
 
repeat
    result = messageBox(myMessage) 
until result == MessageBoxResult.button2 or result == MessageBoxResult.escape

1 Comment