5.2 KiB
5.2 KiB
BaseElement
The base class for all UI elements in Basalt. This class provides basic properties and event handling functionality.
Extends: PropertySystem
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| type | string | BaseElement | The type identifier of the element |
| id | string | BaseElement | The unique identifier for the element |
| name | string | BaseElement | The name of the element |
| eventCallbacks | table | BaseElement | The event callbacks for the element |
| enabled | boolean | BaseElement | Whether the element is enabled or not |
Functions
| Method | Returns | Description |
|---|---|---|
| BaseElement.defineEvent | - | Registers a new event listener for the element (on class level) |
| BaseElement.registerEventCallback | - | Registers a new event callback for the element (on class level) |
| BaseElement.new | table | Creates a new BaseElement instance |
| BaseElement:init | table | Initializes the BaseElement instance |
| BaseElement:postInit | table | Post initialization |
| BaseElement:isType | boolean | Checks if the element is a specific type |
| BaseElement:listenEvent | table | Enables or disables event listening for a specific event |
| BaseElement:registerCallback | table | Registers a callback function |
| BaseElement:fireEvent | table | Triggers an event and calls all registered callbacks |
| BaseElement:dispatchEvent | handled | Handles all events |
| BaseElement:handleEvent | handled | The default event handler for all events |
| BaseElement:onChange | table | Observes a property and calls a callback when it changes |
| BaseElement:getBaseFrame | BaseFrame | Returns the base frame of the element |
| BaseElement:destroy | - | Destroys the element and cleans up all references |
| BaseElement:updateRender | table | Requests a render update for this element |
BaseElement.defineEvent(class, eventName, requiredEvent?)
Registers a new event listener for the element (on class level)
Parameters
classtableThe class to registereventNamestringThe name of the event to registerrequiredEvent(optional)stringThe name of the required event (optional)
BaseElement.registerEventCallback(class, callbackName, string)
Registers a new event callback for the element (on class level)
Parameters
classtableThe class to registercallbackNamestringThe name of the callback to registerstringThenames of the events to register the callback for
BaseElement.new()
Returns
tableThenewly created BaseElement instance
BaseElement:init(props, basalt)
Parameters
propstableThe properties to initialize the element withbasalttableThe basalt instance
Returns
tableselfThe initialized instance
BaseElement:postInit()
Returns
tableselfThe BaseElement instance
BaseElement:isType(type)
Checks if the element is a specific type
Parameters
typestringThe type to check for
Returns
booleanisTypeWhether the element is of the specified type
BaseElement:listenEvent(eventName, enable?)
Enables or disables event listening for a specific event
Parameters
eventNamestringThe name of the event to listen forenable(optional)booleanWhether to enable or disable the event (default: true)
Returns
tableselfThe BaseElement instance
BaseElement:registerCallback(event, callback)
Registers a callback function for an event
Parameters
eventstringThe event to register the callback forcallbackfunctionThe callback function to register
Returns
tableselfThe BaseElement instance
BaseElement:fireEvent(event, any)
Triggers an event and calls all registered callbacks
Parameters
eventstringThe event to fireanyAdditionalarguments to pass to the callbacks
Returns
tableselfThe BaseElement instance
BaseElement:dispatchEvent(event)
Parameters
eventstringThe event to handle
Returns
handledWhetherthe event was handled
BaseElement:handleEvent(event)
Parameters
eventstringThe event to handle
Returns
handledWhetherthe event was handled
BaseElement:onChange(property, callback)
Observes a property and calls a callback when it changes
Parameters
propertystringThe property to observecallbackfunctionThe callback to call when the property changes
Returns
tableselfThe BaseElement instance
BaseElement:getBaseFrame()
Returns the base frame of the element
Returns
BaseFrameBaseFrameThe base frame of the element
BaseElement:destroy()
Destroys the element and cleans up all references
BaseElement:updateRender()
Requests a render update for this element
Returns
tableselfThe BaseElement instance