MessageBox
public class MessageBox
Message box displays a modal message to the user, with a title, a message and a series of options that the user can choose from.
There are a couple of options:
query
is used to show a message with buttonserror
is similar to query, but uses the error color scheme for the dialogsinfo
merely takes a title and message, it is informational only, so the button “ok” is added
The following example pops up a Message Box with 50 columns, and 7 lines, with the specified title and text, plus two buttons. The value -1 is returned when the user cancels the dialog by pressing the ESC key.
-
Displays a message modally with the specified list of buttons.
This displays a message box with the provided title, message as well as a list of strings for the buttons. It optionally can take a width and height, if those are not provided, they will be computed.
Declaration
Swift
public static func query(_ title: String, message: String, buttons: [String], width: Int? = nil, height: Int? = nil, completion: @escaping (_ result: Int) -> ())
Parameters
title
the title for the dialog box
message
the message to display inside the dialog box, it can contain multiple lines
buttons
an array of strings that will be used for the buttons. The first uppercase letter in each button becomes the hotkey
width
optional desired width, if not specified, this is auto-computed
height
optional desired heigh, if not specified, this is auot-computed
completion
function to invoke when the user selects a result, the parameter is the index of the button selected, or -1 if the user pressed the ESC key
-
Displays an error message modally with the specified list of buttons.
This displays a message box with the provided title, message as well as a list of strings for the buttons. It optionally can take a width and height, if those are not provided, they will be computed.
Declaration
Swift
public static func error(_ title: String, message: String, buttons: [String], width: Int? = nil, height: Int? = nil, completion: @escaping (_ result: Int) -> ())
Parameters
title
the title for the dialog box
message
the message to display inside the dialog box, it can contain multiple lines
buttons
an array of strings that will be used for the buttons. The first uppercase letter in each button becomes the hotkey
width
optional desired width, if not specified, this is auto-computed
height
optional desired heigh, if not specified, this is auot-computed
completion
function to invoke when the user selects a result, the parameter is the index of the button selected, or -1 if the user pressed the ESC key
-
Displays an informational message with the specified title It optionally can take a width and height, if those are not provided, they will be computed.
Declaration
Swift
public static func info(_ title: String, message: String, width: Int? = nil, height: Int? = nil, completion: @escaping (_ result: Int) -> ())
Parameters
title
the title for the dialog box
message
the message to display inside the dialog box, it can contain multiple lines
width
optional desired width, if not specified, this is auto-computed
height
optional desired heigh, if not specified, this is auot-computed