Module attribute

Widget attributes.

This module defines "attributes" (special fields) that are recognized by all widgets. Their interpretation may vary depending on the type of widget. Some widget types may also recognize additional attributes.

Setting attributes can have side effects. For example, setting height or width causes the parent widget and its descendants to recalculate their size and position.

Attributes

type Type of widget.
id Widget identifier.
value Widget value.
style Widget style.
status Status message.
scroll Scroll ability.

Keyboard Attributes

focusable Focusable.
key Keyboard shortcut.

Size Attributes

flow Flow axis.
width Width.
height Height.
minwidth Minimum width.
minheight Minimum height.

Font Attributes

font Font path.
size Font size.

Text Attributes

text Text to display.
color Text color.
align Text and icon alignment.
wrap Wrap text onto multiple lines.

Visual Attributes

background Background color.
outline Outline color.
slices Slice image.
margin Margin size.
padding Padding size.
icon Icon path.

Attributes

type
Type of widget.

Should contain a string identifying the widget's type. After the layout is built, may be replaced by an array of strings identifying multiple types. This is used internally by some widgets to provide information about the widget's state to the theme (themes describe the appearance of widgets according to their type).

If a type is registered with the widget's layout, the registered type initializer function will run once when the widget is constructed.

See also:

id
Widget identifier.

Should contain a unique string identifying the widget, if present.

A reference to the widget will be stored in the associated layout in a property having the same name as the widget's id.

Setting this attribute re-registers the widget with its layout.

value
Widget value.

Some widget types expect the value to be of a specific type and within a specific range. For example, slider and progress widgets expect a normalized number, text widgets expect a string, and check and radio widgets expect a boolean.

Setting this attribute bubbles the Change event.

style
Widget style.

Should contain a string or array of strings identifying style rules to be applied to the widget. When resolving any attribute with a nil value, these style rules are searched for a corresponding attribute.

Setting this attribute resets the Font and Text object associated with this widget.

Setting this attribute recalculates the size and position of the parent widget and its descendants.

status

Status message.

Should contain a string with a short message describing the purpose or state of the widget.

This message will appear in the last created status widget in the same layout, or in the master layout if one exists.

  • This attribute cascades.
scroll
Scroll ability.

Should contain true or false (or nil).

If set to true, moving the scroll wheel over the widget will adjust its scroll position when the widget's contents overflow its boundary.

Keyboard Attributes

focusable
Focusable.

Should contain true if the widget can be focused by pressing the tab key.

key
Keyboard shortcut.

Should contain a string representing a key and optional modifiers, separated by dashes; for example 'ctrl-c' or 'alt-shift-escape'.

Pressing this key combination bubbles a Press event on the widget, as if it had been pressed with a mouse or touch interface.

Setting this attribute re-registers the widget with its layout.

Size Attributes

Setting these attributes recalculates the size and position of the parent widget and its descendants.
flow
Flow axis.

Should equal either 'x' or 'y'. Defaults to 'y'.

This attribute determines the placement and default dimensions of any child widgets.

When flow is 'x', the height of child widgets defaults to this widget's height, and each child is placed to the right of the previous child. When flow is 'y', the width of child widgets defaults to this widget's width, and each child is placed below the previous child.

Setting this attribute resets the Text object associated with this widget.

width
Width.

This attribute may not always hold a numeric value. To get the calculated width, use Widget:getWidth.

Setting this attribute when the wrap attribute is also present resets the Text object associated with this widget.

height
Height.

This attribute may not always hold a numeric value. To get the calculated height, use Widget:getHeight.

minwidth
Minimum width.
minheight
Minimum height.

Font Attributes

Setting these attributes resets the Font and Text objects associated with the widget.
font

Font path.

Should contain a path to a TrueType font to use for displaying this widget's text.

  • This attribute cascades.
size

Font size.

Should contain a number representing the size of the font, in points. Defaults to 12.

  • This attribute cascades.

Text Attributes

Setting these attributes resets the Text object associated with the widget.
text
Text to display.
color

Text color.

Should contain an array with 3 or 4 values (RGB or RGBA) from 0 to 255.

  • This attribute cascades.
align

Text and icon alignment.

Should contain a string defining vertical and horizontal alignment. Vertical alignment is defined by either 'top', 'middle', or 'bottom', and horizontal alignment is defined by either 'left', 'center', or 'right'.

For example, align = 'top left'

  • This attribute cascades.
wrap

Wrap text onto multiple lines.

Should contain true for multiline text, or false or nil for a single line. Even text containing line breaks will display as a single line when this attribute is not set to true.

  • This attribute cascades.

Visual Attributes

background
Background color.

Should contain an array with 3 or 4 values (RGB or RGBA) from 0 to 255.

outline
Outline color.

Should contain an array with 3 or 4 values (RGB or RGBA) from 0 to 255.

slices
Slice image.

Should contain a path to an image with "slices" to display for this widget.

margin
Margin size.

The margin area occupies space outside of the outline and slices.

padding
Padding size.

The padding area occupies space inside the outline and slices, and outside the space where the icon and text and any child widgets appear.

icon
Icon path.

Should contain a path to an image file.

generated by LDoc 1.4.3 Last updated 2015-12-17 04:20:17