Lysa.ui  0.0
Lysa 3D Engine
Menu Class Referenceabstract

Detailed Description

A vertical list of text items, optionally split into groups by separator lines. Fires OnSelectItem when an item is clicked.

Inherits from: Widget

Lua full name: lysa.ui.Menu

Public Member Functions

integer add_item (label: string)
 Adds an item at the end of the menu and returns its 0-based index, separators excluded. More...
 
integer add_item (label: string, shortcut: string)
 Adds an item with a right-aligned shortcut text. More...
 
integer add_item (label: string, shortcut: string, resource: string, shortcut_resource: string)
 Adds an item with a shortcut, loading the item and shortcut styles from resource strings. More...
 
integer add_item (label: string, shortcut: string, resource: string, shortcut_resource: string, leading: Widget)
 Adds an item displaying the given widget (check mark, radio button, ...) at the left of the text. More...
 
nil add_separator ()
 Adds a line separating the previous items from the next ones. More...
 
nil add_separator (resource: string)
 Adds a separator line, loading its style from a resource string. More...
 
nil remove_all_items ()
 Removes all the items and separators. More...
 
Text|nil get_item (index: integer)
 Returns the text widget of an item, or nil for an invalid index. More...
 
Text|nil get_item_shortcut (index: integer)
 Returns the shortcut text widget of an item, or nil if the item has no shortcut. More...
 
integer get_item_at (x: number, y: number)
 Returns the index of the item at the given position, or -1 if there is none. More...
 
nil highlight (index: integer)
 Highlights an item, -1 removes the highlight. More...
 
nil set_resources (res_separator: string, res_highlight: string)
 Reloads the visual style: res_separator = separator lines, res_highlight = highlight of the item under the mouse. More...
 

Properties

integer count
 The number of items, separators excluded. (read-only)
 
integer highlighted
 The index of the highlighted item, or -1. (read-only)
 
number item_padding
 The space between the borders of an item and its text, applied to the next added items.
 
number content_height
 The height needed to display all the items and separators. (read-only)
 
number content_width
 The width needed to display the widest item, shortcut included. (read-only)
 

Member Function Documentation

integer add_item ( string  label)

Adds an item at the end of the menu and returns its 0-based index, separators excluded.

Parameters
labelstring
Returns
integer
integer add_item ( string  label,
string  shortcut)

Adds an item with a right-aligned shortcut text.

Parameters
labelstring
shortcutstring
Returns
integer
integer add_item ( string  label,
string  shortcut,
string  resource,
string  shortcut_resource)

Adds an item with a shortcut, loading the item and shortcut styles from resource strings.

Parameters
labelstring
shortcutstring
resourcestring
shortcut_resourcestring
Returns
integer
integer add_item ( string  label,
string  shortcut,
string  resource,
string  shortcut_resource,
Widget  leading)

Adds an item displaying the given widget (check mark, radio button, ...) at the left of the text.

Parameters
labelstring
shortcutstring
resourcestring
shortcut_resourcestring
leadingWidget
Returns
integer
nil add_separator ( )

Adds a line separating the previous items from the next ones.

nil add_separator ( string  resource)

Adds a separator line, loading its style from a resource string.

Parameters
resourcestring
nil remove_all_items ( )

Removes all the items and separators.

Text|nil get_item ( integer  index)

Returns the text widget of an item, or nil for an invalid index.

Parameters
indexinteger
Returns
Text|nil
Text|nil get_item_shortcut ( integer  index)

Returns the shortcut text widget of an item, or nil if the item has no shortcut.

Parameters
indexinteger
Returns
Text|nil
integer get_item_at ( number  x,
number  y)

Returns the index of the item at the given position, or -1 if there is none.

Parameters
xnumber
ynumber
Returns
integer
nil highlight ( integer  index)

Highlights an item, -1 removes the highlight.

Parameters
indexinteger
nil set_resources ( string  res_separator,
string  res_highlight)

Reloads the visual style: res_separator = separator lines, res_highlight = highlight of the item under the mouse.

Parameters
res_separatorstring
res_highlightstring

Property Documentation

integer count

The number of items, separators excluded. (read-only)

integer highlighted

The index of the highlighted item, or -1. (read-only)

number item_padding

The space between the borders of an item and its text, applied to the next added items.

number content_height

The height needed to display all the items and separators. (read-only)

number content_width

The width needed to display the widest item, shortcut included. (read-only)