BaseFrame
Extends: Container
Functions
| Method | Returns | Description |
|---|---|---|
| BaseFrame:initializeState | BaseFrame | Initializes a new state |
BaseFrame:initializeState(self, name, default, persist?, path?)
Initializes a new state for this element
Parameters
selfBaseFrameThe element to initialize state fornamestringThe name of the statedefaultanyThe default value of the statepersist(optional)booleanWhether to persist the state to diskpath(optional)stringCustom file path for persistence
Returns
BaseFrameselfThe element instance
BaseElement
This is the state plugin. It provides a state management system for UI elements with support forpersistent states, computed states, and state sharing between elements.
Functions
| Method | Returns | Description |
|---|---|---|
| BaseElement:setState | BaseElement | Sets a state value |
| BaseElement:getState | any | Gets a state value |
| BaseElement:onStateChange | BaseElement | Watches for state changes |
| BaseElement:removeStateChange | BaseElement | Removes a state change observer |
| BaseElement:bind | BaseElement | Binds a property to a state |
BaseElement:setState(self, name, value)
Sets the value of a state
Parameters
selfBaseElementThe element to set state fornamestringThe name of the statevalueanyThe new value for the state
Returns
BaseElementselfThe element instance
BaseElement:getState(self, name)
Gets the value of a state
Parameters
selfBaseElementThe element to get state fromnamestringThe name of the state
Returns
anyvalueThe current state value
BaseElement:onStateChange(self, stateName, callback)
Registers a callback for state changes
Parameters
selfBaseElementThe element to watchstateNamestringThe state to watchcallbackfunctionCalled with (element, newValue, oldValue)
Returns
BaseElementselfThe element instance
BaseElement:removeStateChange(self, stateName, callback)
Removes a state change observer
Parameters
selfBaseElementThe element to remove observer fromstateNamestringThe state to remove observer fromcallbackfunctionThe callback function to remove
Returns
BaseElementselfThe element instance
BaseElement:bind(self, propertyName, stateName)
Binds a property to a state
Parameters
selfBaseElementThe element to bindpropertyNamestringThe property to bindstateNamestringThe state to bind to (optional, uses propertyName if not provided)
Returns
BaseElementselfThe element instance