- Button
- Constants
- Container
- Label
- LinearContainer
- ListBox
- Object
- Root
- ScrollBar
- ScrollWidget
- TextArea
- TextField
- Utility
- Widget
Inheritance: Button > Widget > Object
Can be clicked using the mouse, triggering a custom onPressed() callback.
Button constructor.
Parameters:
- root (Root): The root widget
- text (string): Text to display on the Button.
Event handler called when a Button is pressed. Override this method on a Button instance to set its behavior.
List of events that should be passed to the currently focused widget (e.g. keyboard events)
Enum used to specify layouts within LinearContainers.
- LinearAxis.CENTER: center the widget within its cell
- LinearAxis.START: align the widget to the top (HORIZONTAL container) or left (VERTICAL) of its cell
- LinearAxis.END: align the widget to the bottom (HORIZONTAL container) or right (VERTICAL) of its cell
Enum used to specify layouts within LinearContainers.
- LinearAxis.HORIZONTAL: X axis
- LinearAxis.VERTICAL: Y axis
Various special characters provided by ComputerCraft:
MINIMIZE, MAXIMIZE, STRIPES, TRI_RIGHT, TRI_LEFT, TRI_UP, TRI_DOWN, ARROW_UP, ARROW_DOWN, ARROW_RIGHT, ARROW_LEFT, ARROW_LR, ARROW_UD
List of events that should only be passed to the topmost widget directly under the mouse cursor (clicking, scrolling)
Inheritance: Container > Widget > Object
Base class for all widgets that can contain other gui widgets.
Container constructor.
Add a child widget to the Container.
Updates the position and size of all widgets within the Container. Specialized behavior is provided by subclasses of Container.
Inheritance: Label > Widget > Object
Displays custom text.
Label constructor.
Parameters:
- root (Root): The root widget
- text (string): Text to display on the Label.
Returns the label's text padded or trimmed to the size of the label.
Inheritance: LinearContainer > Container > Widget > Object
Container that arranges child widgets in a horizontal or vertical line. Padding at the edges and spacing between widgets can be specified. Child widgets may be set to fill the primary and/or secondary axes of the container. If multiple widgets are set to fill the primary axis, then the free space will be evenly distributed between them.
LinearContainer constructor.
Parameters:
- root (Root): The root widget
- axis (LinearAxis): The primary axis of this container (HORIZONAL or VERTICAL).
- spacing (int): Spacing between contained widgets.
- padding (int): Padding between the first/last widgets and the container's edge.
Adds a widget to the LinearContainer
Parameters:
- child (Widget): the widget to add
- fillPrimary (bool): whether the widget should fill the main axis specified in the constructor
- fillSecondary (bool): whether the widget should fill the other axis perpendicular to the primary one
- align (LinearAlign): whether the widget should be centered, left-aligned, or right-aligned
Inheritance: ListBox > ScrollWidget > Widget > Object
List box. Allows an array of choices to be displayed, one of which can be selected at a time. Can be scrolled using the mouse wheel or a ScrollBar widget, and is able to efficiently display large amounts of items.
ListBox constructor.
Parameters:
- root (Root): The root widget
- cols (int): The preferred width of the ListBox
- rows (int): The preferred height of the ListBox
- items (string[]): Items contained within the ListBox
Event handler called when the selected item is changed. Override this method to receive selection events.
Implements basic inheritance features.
Object constructor.
To create an instance of an Object, call Object(args), which will instantiate the class and then call the Object's constructor to set up the instance. The process works the same way for subclasses: just replace Object with the name of the class you are instantiating.
Internally, the constructor is named Object:init(...). Override this init method to specify initialization behavior for an Object subclass. An object's init() method may call its super class's init() if desired (use ClassName.superClass.init(self,...))
Returns true if the Object is an instance of the provided class or a subclass.
Creates a subclass of an existing class.
Inheritance: Root > Container > Widget > Object
The root widget of the user interface. Handles focus, resizing, and other events.
Root constructor.
Shows the GUI and runs its event loop.
Called internally to render the root's first frame.
Inheritance: ScrollBar > Widget > Object
Scroll bar. Allows greater control over a scrolling widget such as a ListBox.
ScrollBar constructor.
Parameters:
- root (Root): The root widget
- scrollWidget (ScrollWidget): The widget this ScrollBar should scroll
Inheritance: ScrollWidget > Widget > Object
Base class for scrollable widgets
Widget constructor.
Returns the scroll range of the widget
Inheritance: TextArea > Widget > Object
A text area for editing multi-line text. Unfinished.
TextArea constructor.
Parameters:
- root (Root): The root widget
- cols (int): The preferred width of the text area
- rows (int): The preferred height of the text area
- text (string): Initial contents of the text area
Gets the text within the text area.
Sets the text within the text area.
Inheritance: TextField > Widget > Object
A text field that allows users to type text within it.
TextField constructor.
Parameters:
- root (Root): The root widget
- length (int): Width of the text field in characters.
- text (string): Initial contents of the TextField.
Gets the text within the TextField
Event handler called when the text in a TextField is edited. Override this method on an instance to set custom behavior.
Sets the text within the TextField
Base class for GUI elements.
Widget constructor.
Returns true if the coordinates x, y are within the widget's bounding box.
Post-render callback for focused widget. Used to position text field cursor.
Returns the widget's preferred minimum size.
Event handler called when a character is typed and the widget is in focus.
Handles any input events recieved by the widget and passes them to the appropriate handler functions. Return true from an event handler to consume the event and prevent it from being passed on to other widgets. Event consumption is mainly useful for mouse_click and mouse_scroll.
Event handler called when the widget enters or leaves focus.
Event handler called when a key is pressed or held and the widget is in focus.
Event handler called when a key is released and the widget is in focus.
Event handler called when the widget's layout is updated.
Event handler called when a mouse button is released and the widget is in focus.
Event handler called when the widget is dragged.
Event handler called when the mouse wheel is scrolled over the widget.
Event handler called when a mouse button is pressed over the widget.
Event handler called when text is pasted and the widget is in focus.
Event handler called when the GUI is repainted.
Widget render callbacks. Override these to draw a widget.