Class Widget

Widget class.

Functions

Widget.register (name, decorator) Register a custom widget type.

Methods

Widget:bubbleEvent (eventName[, data]) Fire an event on this widget and each ancestor.
Widget:getPreviousSibling () Get widget's previous sibling.
Widget:getNextSibling () Get widget's next sibling.
Widget:focus () Attempt to focus the widget.
Widget:getNextNeighbor () Get the next widget, depth-first.
Widget:getPreviousNeighbor () Get the previous widget, depth-first.
Widget:addChild (data) Add a child to this widget.
Widget:getX () Get the widget's X coordinate.
Widget:getY () Get the widget's Y coordinate.
Widget:getWidth () Get the widget's calculated width.
Widget:getHeight () Get the widget's calculated height.
Widget:getContentWidth () Get the content width.
Widget:getContentHeight () Get the content height.
Widget:getRectangle (useMargin, usePadding) Get x/y/width/height values describing a rectangle within the widget.
Widget:isAt (x, y) Determine whether a point is within a widget.
Widget:reshape () Reshape the widget.

Constructor

Luigi.Widget (layout[, data]) Widget pseudo-constructor.


Functions

Methods
Widget.register (name, decorator)
Register a custom widget type.

Parameters:

  • name string A unique name for this type of widget.
  • decorator function(Widget) An initialization function for this type of widget.

Methods

Widget:bubbleEvent (eventName[, data])
Fire an event on this widget and each ancestor.

If any event handler returns non-nil, stop the event from propagating.

Parameters:

  • eventName string The name of the Event.
  • data table Information about the event to send to handlers. (optional)

Returns:

    mixed The first value returned by an event handler.
Widget:getPreviousSibling ()
Get widget's previous sibling.

Returns:

    Widget or nil The widget's previous sibling, if any.
Widget:getNextSibling ()
Get widget's next sibling.

Returns:

    Widget or nil The widget's next sibling, if any.
Widget:focus ()
Attempt to focus the widget.

Unfocus currently focused widget, and focus this widget if it's focusable.

Returns:

    boolean true if this widget was focused, else false.
Widget:getNextNeighbor ()
Get the next widget, depth-first.

If the widget has children, returns the first child. Otherwise, returns the next sibling of the nearest possible ancestor. Cycles back around to the layout root from the last widget in the tree.

Returns:

    Widget The next widget in the tree.
Widget:getPreviousNeighbor ()
Get the previous widget, depth-first.

Uses the reverse of the traversal order used by getNextNeighbor. Cycles back around to the last widget in the tree from the layout root.

Returns:

    Widget The previous widget in the tree.
Widget:addChild (data)
Add a child to this widget.

Parameters:

  • data Widget or table A widget or definition table representing a widget.

Returns:

    Widget The newly added child widget.
Widget:getX ()
Get the widget's X coordinate.

Returns:

    number The widget's X coordinate.
Widget:getY ()
Get the widget's Y coordinate.

Returns:

    number The widget's Y coordinate.
Widget:getWidth ()
Get the widget's calculated width.

Returns:

    number The widget's calculated width.
Widget:getHeight ()
Get the widget's calculated height.

Returns:

    number The widget's calculated height.
Widget:getContentWidth ()
Get the content width.

Gets the combined width of the widget's children.

Returns:

    number The content width.
Widget:getContentHeight ()
Get the content height.

Gets the combined height of the widget's children.

Returns:

    number The content height.
Widget:getRectangle (useMargin, usePadding)
Get x/y/width/height values describing a rectangle within the widget.

Parameters:

  • useMargin boolean Whether to adjust the rectangle based on the widget's margin.
  • usePadding boolean Whether to adjust the rectangle based on the widget's padding.

Returns:

  1. number The upper left corner's X position.
  2. number The upper left corner's Y position.
  3. number The rectangle's width
  4. number The rectangle's height
Widget:isAt (x, y)
Determine whether a point is within a widget.

Parameters:

  • x number The point's X coordinate.
  • y number The point's Y coordinate.

Returns:

    boolean true if the point is within the widget, else false.
Widget:reshape ()
Reshape the widget.

Clears calculated widget dimensions, allowing them to be recalculated, and fires a Reshape event (does not bubble). Called recursively for each child.

When setting a widget's width or height, this function is automatically called on the parent widget.

Constructor

Luigi.Widget (layout[, data])
Widget pseudo-constructor.

Parameters:

  • layout Layout The layout this widget belongs to.
  • data table The data definition table for this widget. This table is identical to the constructed widget. (optional)

Returns:

    Widget A Widget instance.
generated by LDoc 1.4.3 Last updated 2015-12-07 03:00:19