GRID CARTOGRAPHER 4
Shortcuts

UITextDialog

2019-04-12

Create text-based dialog boxes using this helper class. It handles creating an empty screen area with a row of options. The content of the dialog box is up to you!

Requirements

Header | uikit/textdialog.nut

Methods

Constructor

UITextDialog( setup: table ): instance

Create an instance of the UITextDialog class. The dialog is configured using a table with the following slots:

Key Value
caption:string The caption for the dialog, displayed in the center at the top of the dialog border.
width:int The inner width of the dialog in characters.
height:int The inner height of the dialog.
id:string A user defined identifier for the dialog, used for future reference.
form:array An array of controls for the dialog. This is currently work in progress and not yet documented. Apologies for any inconvenience caused.
options:array A list of option buttons to display along the bottom of the dialog. At least one option is required for all dialogs, if none are present a default OK button will be created automatically.
OnSelectOption:function A callback function that is executed when an option selection is made. The function is invoked as:

OnSelectOption(sender,selection)

If this function is not present a default function is called that closes the dialog and returns the selected option index as an integer.

The setup options slot must contain an array of tables with the following slots:

Key Value
space:int Controls the number of spaces to place before the option. This setting is optional and if omitted will default to 1.
text:string The y position of the cursor in characters (relative to the top-left of the console).

OpenDialog

dialog.OpenDialog(): *

Open a modal dialog and handle user input until a selection is made. The function will return once the dialog box has closed. The value returned is that passed to EndDialog.

EndDialog

dialog.EndDialog( result: * ) : void

This function causes the given dialog to end. Typically, this is invoked from the OnSelectOption callback.

MessageBox

UITextDialog.MessageBox( message: string [,options: array<string>] ): string

This is a static helper function to create a simple message box dialog. It contains message text and buttons. The options parameter is a simple array of caption strings, if omitted, a default OK button will be created. The function returns the selected option text as a string.