dialog.eh

Common dialogs. More...

use "dialog.eh"

Functions

def run_alert(title: String, msg: String, img: Image = null, timeout: Int = 1500);
def run_colorchooser(title: String, color: Int = 0): Int;
def run_dirchooser(title: String, current: String): String;
def run_editbox(title: String, text: String = "", mode: Int = EDIT_ANY, maxsize: Int = 50): String;
def run_filechooser(title: String, current: String, filters: [String] = null): String;
def run_listbox(title: String, lines: [String], images: [Image] = null): Int;
def run_msgbox(title: String, msg: String, variants: [String], img: Image = null): Int;
def run_yesno(title: String, msg: String, y: String = "Yes", n: String = "No", img: Image = null): Bool;
def Screen.show_modal(): Menu;

Description

See description of each function for using particular dialog.

Function details

def Screen.show_modal(): Menu;
Shows this screen and returns selected menu item. Before calling this function make sure that screen has at least one menu item attached. Otherwise program will hang.

def run_alert(title: String, msg: String, img: Image = null, timeout: Int = 1500);
Shows dialog with a message and "Close" button. The message box hides automatically after specified timeout. If timeout is 0, message is shown until "Close" is pressed.

def run_yesno(title: String, msg: String, y: String = "Yes", n: String = "No", img: Image = null): Bool;
Shows dialog with a message and two menu items "Yes" and "No". Returns true if "Yes" was pressed and "No" otherwise. Captions are configurable so you may use other variants like "Ok" and "Cancel".

def run_msgbox(title: String, msg: String, variants: [String], img: Image = null): Int;
Shows dialog with a message and a given set of menu items. Captions of menu items are given in variants array. First item in variants is the default variant, it is assigned MT_OK category. The function returns number of selected menu item according to variants array.

def run_listbox(title: String, lines: [String], images: [Image] = null): Int;
Shows dialog with a given list of variants. Dialog has two menu items - "Select" and "Cancel". If "Select" is chosen then index of selected list item is returned. On "Cancel" function returns -1. If images is not null then it must be the same length as lines.

def run_editbox(title: String, text: String = "", mode: Int = EDIT_ANY, maxsize: Int = 50): String;
Shows dialog which allows to input text. Dialog has two menu items - "Ok" and "Cancel". If "Ok" is pressed then text from dialog is returned. On "Cancel" function returns null. Argument maxsize defines maximum number of characters that can be inputed. Note, that due to limitations of particular platform actual number of characters may be lower than you specify. For valid values of argument mode see ui_edit.eh

def run_colorchooser(title: String, color: Int = 0): Int;
Shows dialog which allows to choose color. Dialog has two menu items - "Ok" and "Cancel". If "Ok" is pressed then integer code of selected color is returned. On "Cancel" function returns -1. Argument color defines initial color in dialog.

def run_dirchooser(title: String, current: String): String;
Shows dialog that allows to choose directory. Dialog has two menu items - "Ok" and "Cancel". If "Ok" is pressed then path to the selected directory is returned. On "Cancel" function returns null. Argument current specifies starting directory. It may be a file in which case directory parent to that file is used.

def run_filechooser(title: String, current: String, filters: [String] = null): String;
Shows dialog that allows to choose file. Dialog has two menu items - "Ok" and "Cancel". If "Ok" is pressed then path to the selected file is returned. On "Cancel" function returns null. Argument current specifies starting file. If filters is non-null then it must contain at least one string. Strings in filters define file patterns, only files that match given patterns are shown.