6.8 KiB
Container : VisualElement
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| children | table | {} | The children of the container |
| childrenSorted | boolean | true | Whether the children are sorted |
| childrenEventsSorted | boolean | true | Whether the children events are sorted |
| childrenEvents | table | {} | The children events of the container |
| eventListenerCount | table | {} | The event listener count of the container |
| focusedChild | table | nil | The focused child of the container |
| visibleChildren | table | {} | The visible children of the container |
| visibleChildrenEvents | table | {} | The visible children events of the container |
Functions
| Method | Returns | Description |
|---|---|---|
| Container.new | Container | |
| Container:addChild | Container | |
| Container:blit | Container | |
| Container:char | boolean | |
| Container:clear | Container | |
| Container:getChild | Container? | |
| Container:handleEvent | boolean | |
| Container:init | - | |
| Container:isChildVisible | boolean | |
| Container:key | boolean | |
| Container:key_up | boolean | |
| Container:mouse_click | boolean | |
| Container:mouse_up | boolean | |
| Container:multiBlit | Container | |
| Container:registerChildEvent | Container | |
| Container:registerChildrenEvents | Container | |
| Container:removeChild | Container | |
| Container:removeChildrenEvents | Container | |
| Container:render | - | |
| Container:sortChildren | Container | |
| Container:sortChildrenEvents | Container | |
| Container:textFg | Container | |
| Container:unregisterChildEvent | Container |
Container.new()
Creates a new Container instance
Returns
ContainerselfThe new container instance
Container:addChild(child)
Adds a child to the container
Parameters
childtableThe child to add
Returns
ContainerselfThe container instance
Container:blit(x, y, text, fg, bg)
Draws a line of text and fg and bg as colors, it is usually used in the render loop
Parameters
xnumberThe x position to draw the textynumberThe y position to draw the texttextstringThe text to drawfgstringThe foreground color of the textbgstringThe background color of the text
Returns
ContainerselfThe container instance
Container:char(char)
Handles char events
Parameters
charstringThe character that was pressed
Returns
booleanWhetherthe event was handled
Container:clear()
Clears the container
Returns
ContainerselfThe container instance
Container:getChild(path)
Removes a child from the container
Parameters
pathstringThe path to the child to remove
Returns
Container?selfThe container instance
Container:handleEvent(event)
Default handler for events @vararg any The event arguments
Parameters
eventstringThe event to handle
Returns
booleanWhetherthe event was handled
Container:init(props, basalt)
Initializes the Container instance
Parameters
propstableThe properties to initialize the element withbasalttableThe basalt instance
Container:isChildVisible(child)
Returns whether a child is visible
Parameters
childtableThe child to check
Returns
booleanbooleanthe child is visible
Container:key(key)
Handles key events
Parameters
keynumberThe key that was pressed
Returns
booleanWhetherthe event was handled
Container:key_up(key)
Handles key up events
Parameters
keynumberThe key that was released
Returns
booleanWhetherthe event was handled
Container:mouse_click(button, x, y)
Handles mouse click events
Parameters
buttonnumberThe button that was clickedxnumberThe x position of the clickynumberThe y position of the click
Returns
booleanWhetherthe event was handled
Container:mouse_up(button, x, y)
Handles mouse up events
Parameters
buttonnumberThe button that was clickedxnumberThe x position of the clickynumberThe y position of the click
Returns
booleanWhetherthe event was handled
Container:multiBlit(x, y, width, height, text, fg, bg)
Draws multiple lines of text, fg and bg strings, it is usually used in the render loop
Parameters
xnumberThe x position to draw the textynumberThe y position to draw the textwidthnumberThe width of the textheightnumberThe height of the texttextstringThe text to drawfgstringThe foreground color of the textbgstringThe background color of the text
Returns
ContainerselfThe container instance
Container:registerChildEvent(child, eventName)
Registers the children events of the container
Parameters
childtableThe child to register events foreventNamestringThe event name to register
Returns
ContainerselfThe container instance
Container:registerChildrenEvents(child)
Registers the children events of the container
Parameters
childtableThe child to register events for
Returns
ContainerselfThe container instance
Container:removeChild(child)
Removes a child from the container
Parameters
childtableThe child to remove
Returns
ContainerselfThe container instance
Container:removeChildrenEvents(child)
Unregisters the children events of the container
Parameters
childtableThe child to unregister events for
Returns
ContainerselfThe container instance
Container:render()
Renders the container
Container:sortChildren()
Sorts the children of the container
Returns
ContainerselfThe container instance
Container:sortChildrenEvents(eventName)
Sorts the children events of the container
Parameters
eventNamestringThe event name to sort
Returns
ContainerselfThe container instance
Container:textFg(x, y, text, fg)
Draws a line of text and fg as color, it is usually used in the render loop
Parameters
xnumberThe x position to draw the textynumberThe y position to draw the texttextstringThe text to drawfgcolorThe foreground color of the text
Returns
ContainerselfThe container instance
Container:unregisterChildEvent(child, eventName)
Unregisters the children events of the container
Parameters
childtableThe child to unregister events foreventNamestringThe event name to unregister
Returns
ContainerselfThe container instance