Skip to content

Container : VisualElement

The container class. It is a visual element that can contain other elements. It is the base class for all containers, like Frames, BaseFrames, and more.

Properties

PropertyTypeDefaultDescription
childrentable{}The children of the container
childrenSortedbooleantrueWhether the children are sorted
childrenEventsSortedbooleantrueWhether the children events are sorted
childrenEventstable{}The children events of the container
eventListenerCounttable{}The event listener count of the container
focusedChildtablenilThe focused child of the container
visibleChildrentable{}The visible children of the container
visibleChildrenEventstable{}The visible children events of the container
offsetXnumber0Horizontal content offset
offsetYnumber0Vertical content offset

Combined Properties

NamePropertiesDescription
offsetoffsetX number, offsetY numberCombined property for offsetX and offsetY

Functions

MethodReturnsDescription
Container:addChildContainerAdds a child to the container
Container:callChildrenEventbooleanCalls a event on all children
Container:clearContainerClears the container
Container:drawBg-
Container:drawFg-
Container:drawText-
Container:getChildContainer?Removes a child from the container
Container:isChildVisiblebooleanReturns whether a child is visible
Container:registerChildEventContainerRegisters the children events of the container
Container:registerChildrenEventsContainerRegisters the children events of the container
Container:removeChildContainerRemoves a child from the container
Container:removeChildrenEventsContainerUnregisters the children events of the container
Container:sortChildrenContainerSorts the children of the container
Container:sortChildrenEventsContainerSorts the children events of the container
Container:unregisterChildEventContainerUnregisters the children events of the container

Protected Functions

MethodReturnsDescription
Container:blitContainerDraws a line of text and fg and bg as colors
Container:charbooleanHandles char events
Container:handleEventbooleanDefault handler for events
Container:init-Initializes the Container instance
Container:keybooleanHandles key events
Container:key_upbooleanHandles key up events
Container:mouse_clickbooleanHandles mouse click events
Container:mouse_dragbooleanHandles mouse drag events
Container:mouse_movebooleanHandles mouse move events
Container:mouse_release-Handles mouse release events
Container:mouse_scrollbooleanHandles mouse scroll events
Container:mouse_upbooleanHandles mouse up events
Container:multiBlitContainerDraws multiple lines of text, fg and bg strings
Container:render-Renders the container
Container:textBgContainerDraws a line of text and bg as color
Container:textFgContainerDraws a line of text and fg as color

Container:addChild(child)

Adds a child to the container

Parameters

  • child table The child to add

Returns

  • Container self The container instance

Container:callChildrenEvent(visibleOnly, event...)

Calls a event on all children

Parameters

  • visibleOnly boolean Whether to only call the event on visible children
  • event string The event to call
  • ... (vararg) any The event arguments

Returns

  • boolean handled Whether the event was handled
  • table? child The child that handled the event

Container:clear()

Clears the container

Returns

  • Container self The container instance

Container:drawBg()

Container:drawFg()

Container:drawText()

Container:getChild(path)

Removes a child from the container

Parameters

  • path string The path to the child to remove

Returns

  • Container? self The container instance

Container:isChildVisible(child)

Returns whether a child is visible

Parameters

  • child table The child to check

Returns

  • boolean boolean the child is visible

Container:registerChildEvent(child, eventName)

Registers the children events of the container

Parameters

  • child table The child to register events for
  • eventName string The event name to register

Returns

  • Container self The container instance

Container:registerChildrenEvents(child)

Registers the children events of the container

Parameters

  • child table The child to register events for

Returns

  • Container self The container instance

Container:removeChild(child)

Removes a child from the container

Parameters

  • child table The child to remove

Returns

  • Container self The container instance

Container:removeChildrenEvents(child)

Unregisters the children events of the container

Parameters

  • child table The child to unregister events for

Returns

  • Container self The container instance

Container:sortChildren()

Sorts the children of the container

Returns

  • Container self The container instance

Container:sortChildrenEvents(eventName)

Sorts the children events of the container

Parameters

  • eventName string The event name to sort

Returns

  • Container self The container instance

Container:unregisterChildEvent(child, eventName)

Unregisters the children events of the container

Parameters

  • child table The child to unregister events for
  • eventName string The event name to unregister

Returns

  • Container self The container instance

Released under the MIT License.