LM.GUI Classes

class LM_View

The LM_View class is the basis for most of the user interface classes available to Moho scripts. It represents a rectangular area in the user interface where some kind of interaction takes place.

Member Functions

void Enable(enable)

Enables or disables a view object. For example, this function is used to gray out a user interface button.

Return value: none
enable (bool): true to enable the view, false to disable it

bool IsEnabled()

Tells whether the view is currently enabled.

Return value (bool): true if the view is enabled, false otherwise

Class LM_BaseWidget

The LM_BaseWidget class is a specialized type of view object. You would never create an LM_BaseWidget object by itslef - instead, common controls like buttons and check boxes are types of LM_BaseWidgets.

Member Functions

void Redraw()

Call this function to force the widget to redraw itself. Ordinarily, widgets take care of this on their own, but you can force it if you need to.

Return value: none

class LM_StaticText

The LM_StaticText class is used to display a non-changing text label in a dialog or toolbar. To create a new static text label, you would use the following function:


LM_StaticText LM.GUI.StaticText(label)

Creates a new LM_StaticText object that can then be added to a dialog or toolbar.

Return value (LM_StaticText): the newly-created text label
label (string): the text to appear

class LM_DynamicText

The LM_DynamicText class is used to display a text label in a dialog or toolbar, whose value can change. To create a new dynamic text label, you would use the following function:


LM_DynamicText LM.GUI.DynamicText(label, width)

Creates a new LM_DynamicText object that can then be added to a dialog or toolbar.

Return value (LM_DynamicText): the newly-created dynamic text
label (string): the initial text label
width (int): the width of the text label in pixels (set this to 0 for automatic sizing)

Member Functions

void SetValue(text)

Set the text label as a string.

Return value: none
text (string): a text string to set as the label

void SetValue(i)

Set the text label as an integer.

Return value: none
i (int): a number to use as the text label

void SetValue(f)

Set the text label as a floating-point number.

Return value: none
f (float): a number to use as the text label

class LM_Divider

The LM_Divider class is a simple vertical or horizontal line used to visually separate user interface elements. To create a new divider, you would use the following function:


LM_Divider LM.GUI.Divider(vertical)

Creates a new LM_Divider object that can then be added to a dialog or toolbar.

Return value (LM_Divider): the newly-created divider
vertical (bool): true to create a vertical divider, false for a horizontal divider

class LM_Button

The LM_Button class represents a basic push button, like the OK and Cancel buttons in a dialog box. To create a new button, you would use the following function:


LM_Button LM.GUI.Button(label, msg)

Creates a new LM_Button object that can then be added to a dialog or toolbar.

Return value (LM_Button): the newly-created button
label (string): the text that should appear on the button
msg (int): a message value to be triggered when the button is pressed

class LM_CheckBox

The LM_CheckBox class is a check box that can be marked on or off. To create a new button, you would use the following function:


LM_CheckBox LM.GUI.CheckBox(label, msg)

Creates a new LM_CheckBox object that can then be added to a dialog or toolbar.

Return value (LM_CheckBox): the newly-created check box
label (string): a text label to appear at the side of the check box
msg (int): a message value to be triggered when the button is pressed

Member Functions

void SetValue(value)

Sets the value of the check box.

Return value: none
value (bool): true to set the box checked, false for unchecked

bool Value()

Returns whether the box is checked or not.

Return value (bool): returns tru if the box is checked, false otherwise

class LM_Menu

The LM_Menu class represents a list of commands. A menu by itself does not appear in the user interface - it must be attached to an LM_PopupMenu widget in order to be placed in a dialog box or toolbar. To create a new menu, you would use the following function:


LM_Menu LM.GUI.Menu(title)

Creates a new LM_Menu object that can then be added to a dialog or toolbar.

Return value (LM_Menu): the newly-created menu
title (string): the menu's title

Member Functions

void AddItem(label, shortcut, msg)

Adds a new command to the bottom of the menu.

Return value: none
label (string): the item's text label
shortcut (char): a shortcut key used to trigger the menu command
msg (int): the message value to send when the command is selected by the user

void AddItemAlphabetically(label, shortcut, msg)

Adds a new command alphabetically to the menu.

Return value: none
label (string): the item's text label
shortcut (char): a shortcut key used to trigger the menu command
msg (int): the message value to send when the command is selected by the user

int CountItems()

Returns the number of commands in the menu.

Return value (int): the number of commands in the menu

void RemoveAllItems()

Removes all commands from a menu, leaving the menu empty.

Return value: none

void SetEnabled(msg, enabled)

Enables or disables a menu command.

Return value: none
msg (int): the message value of the desired command
enabled (bool): true to enable the command, false to disable it

bool IsEnabled(msg)

Checks the enabled status of a menu command.

Return value (bool): true if enabled, false if disabled
msg (int): the message value of the desired command

void SetChecked(msg, checked)

Attaches a checkmark to a menu command.

Return value: none
msg (int): the message value of the desired command
checked (bool): true to add a checkmark, false to remove a checkmark

void SetCheckedLabel(label, checked)

Attaches a checkmark to a menu command.

Return value: none
label (string): the text label of the matching menu command
checked (bool): true to add a checkmark, false to remove a checkmark

bool IsChecked(msg)

Tests whether a menu command is checked.

Return value (bool): true if check, false otherwise
msg (int): the message value of the desired command

void UncheckAll()

Un-checks all commands in the menu.

Return value: none

int FirstChecked()

Returns the id of the first checked command in the menu (starting at 0 for the first item).

Return value (int): the id of the first checked command in the menu

int FirstCheckedMsg()

Returns the message value of the first checked command in the menu.

Return value (int): the message value of the first checked command in the menu

string FirstCheckedLabel()

Returns the text label of the first checked command in the menu.

Return value (string): the text label of the first checked command in the menu

string ItemLabel(msg)

Returns the text label of a command in the menu.

Return value (string): the text label of a command in the menu
msg (int): the message value of the desired command

class LM_RadioButton

The LM_RadioButton class represents one choice among several. Two or more radio buttons are typically used to let the user choose between mutually exclusive options. When one is selected, the other choices get automatically de-selected. To create a new radio button, you would use the following function:


LM_RadioButton LM.GUI.RadioButton(label, msg)

Creates a new LM_RadioButton object that can then be added to a dialog or toolbar.

Return value (LM_RadioButton): the newly-created radio button
label (string): the text that should appear next to the radio button
msg (int): a message value to be triggered when the radio button is clicked

Member Functions

void SetValue(value)

Sets the value of the radio button (whether it is checked or not).

Return value: none
value (bool): true if the button should be checked, false if un-checked

bool Value()

Returns the current value of the radio button.

Return value (bool): true if checked, false if un-checked

class LM_LayoutView

The LM_LayoutView class is used to arrange other user interface objects in a dialog box or toolbar. You never create a layout view yourself - it is provided for you when you create a dialog box or fill in a toolbar.

Member Functions

void AddChild(view, alignment=LM.GUI.ALIGN_CENTER, indent=0)

Add a new widget to the layout. Use this to add user interface controls one at a time to a dialog box.

Return value: none
view (LM_View): the view to add to the layout
alignment (int): how to align the child view - see alignment constants (defaults to LM.GUI.ALIGN_CENTER)
indent (int): how far to indent the child view (defaults to 0)

void AddPadding(pixels=LM.GUI.DEFAULT_PADDING)

Add some blank space to the layout.

Return value: none
pixels (int): how much blank space in pixels

void Indent(amount=LM.GUI.DEFAULT_INDENT)

Begin indenting all further views that get added to the layout.

Return value: none
amount (int): how far to indent in pixels

void Unindent(amount=LM.GUI.DEFAULT_INDENT)

Stop indenting all further views that get added to the layout.

Return value: none
amount (int): how far to un-indent in pixels

void PushH(alignment=LM.GUI.ALIGN_LEFT, padding=-1)

Switch to horizontal layout for the next set of child views to be added.

Return value: none
alignment (int): how to align the horizontal row in the current layout
padding (int): how much padding to provide between elements

void PushV(alignment=LM.GUI.ALIGN_LEFT, padding=-1)

Switch to vertical layout for the next set of child views to be added.

Return value: none
alignment (int): how to align the vertical column in the current layout
padding (int): how much padding to provide between elements

void Pop()

End the current row or column of layout and go back to the style of layout before that row or column was started.

Return value: none

class LM_PopupMenu

The LM_PopupMenu class creates a popup menu widget on the screen. Clicking on this object will bring up the actual menu. To create a new popup menu widget, you would use the following function:


LM_PopupMenu LM.GUI.PopupMenu(width, radioMode)

Creates a new LM_PopupMenu object that can then be added to a dialog or toolbar.

Return value (LM_PopupMenu): the newly-created popup menu
width (int): the width of the popup menu in pixels
radioMode (bool): If true, then only one item can be selected from the popup menu. If false, then the commands in the menu are not selected with a check, but work like normal menu commands.

Member Functions

void SetMenu(menu)

By itself, a popup menu does nothing. Use this function to attach a menu to the widget so that when the user clicks on it, the menu appears.

Return value: none
menu (LM_Menu): the menu object to display when the user clicks on the popup menu

LM_Menu Menu()

Returns the menu object attached to the popup menu.

Return value (LM_Menu): the menu object attached to the popup menu

class LM_PopupDialog

The LM_PopupDialog class creates a popup dialog widget on the screen. Clicking on this object will bring up the actual dialog. To create a new popup dialog widget, you would use the following function:


LM_PopupDialog LM.GUI.PopupDialog(label, lockOpen, msg)

Creates a new LM_PopupDialog object that can then be added to a dialog or toolbar.

Return value (LM_PopupDialog): the newly-created popup dialog
label (string): the text to appear on the popup dialog
lockOpen (bool): If true, the dialog will stay open continuously. If false, the dialog will close when the user clicks on somethign else.
msg (int): the message to be sent when the user clicks to open the dialog

Member Functions

void SetDialog(dialog)

By itself, a popup dialog does nothing. Use this function to attach a dialog to the widget so that when the user clicks on it, the dialog appears.

Return value: none
dialog (LM_SimpleDialog): the dialog object to display when the user clicks on the popup dialog

LM_SimpleDialog Dialog()

Returns the dialog object attached to the popup dialog.

Return value (LM_SimpleDialog): the dialog object attached to the popup dialog

class LM_TextList

The LM_TextList class provides a scrollable list of text items. To create a new text list, you would use the following function:


LM_TextList LM.GUI.TextList(width, heigh, msg)

Creates a new LM_TextList object that can then be added to a dialog or toolbar.

Return value (LM_TextList): the newly-created text list
width (int): width in pixels
height (int): height in pixels
msg (int): the message value to send when the user clicks on an item in the list

Member Functions

int CountItems()

Returns the number of entries in the list.

Return value (int): the number of entries in the list

string GetItem(id)

Returns the string value of an item in the list.

Return value (string): the string value of an item in the list
id (int): the number of the entry (starting with 0 for the first item)

void AddItem(label)

Adds a new text item to the list. The new item appears at the end of the list.

Return value: none
label (string): the text string to add to the list

void AddItemAlphabetically(label)

Adds a new text item to the list. The new item is inserted alphabetically into the list.

Return value: none
label (string): the text string to add to the list

void RemoveItem(id)

Removes an item from the list.

Return value: none
id (int): the number of the entry to remove (starting with 0 for the first item)

void SetSelItem(id)

Selects an item in the list.

Return value: none
id (int): the number of the entry (starting with 0 for the first item)

bool SetSelItem(label)

Selects an item in the list. Instead of selecting the item by number, the item that matches the supplied string is selected.

Return value (bool): true if the item exists and is selected, false if the item cannot be found
label (string): a string matching the item you wish to select

int SelItem()

Returns the id number of the currently selected item (starting with 0 for the first item).

Return value (int): the id number of the currently selected item

string SelItemLabel()

Returns the text string associated with the currently selected item.

Return value (string): the text string associated with the currently selected item

void SetItemLabel(id, label)

Changes the text string associated with an entry in the list.

Return value: none
id (int): the number of the entry (starting with 0 for the first item)
label (string): the new text string to replace that entry in the list

class LM_AngleWidget

The LM_AngleWidget class provides a knob to let the user enter an angle value. To create a new angle widget, you would use the following function:


LM_AngleWidget LM.GUI.AngleWidget(msg)

Creates a new LM_AngleWidget object that can then be added to a dialog or toolbar.

Return value (LM_AngleWidget): the newly-created angle widget
msg (int): the message value to send when the angle is changed by the user

Member Functions

void SetValue(angle)

Sets the angle value of the angle widget.

Return value: none
angle (float): an angle in radians

float Value()

Returns the current angle value.

Return value (float): the current angle value in radians

class LM_Slider

New Feature

[12  >>