1.3 KiB
1.3 KiB
Switch
The Switch is a standard Switch element with click handling and state management.
Extends: VisualElement
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| checked | boolean | Whether | switch is checked |
| text | string | Text | to display next to switch |
| autoSize | boolean | Whether | to automatically size the element to fit switch and text |
| onBackground | number | Background | color when ON |
| offBackground | number | Background | color when OFF |
Functions
| Method | Returns | Description |
|---|---|---|
| Switch.new | table | Creates a new Switch instance |
| Switch:init | - | Initializes the Switch instance |
| Switch:mouse_click | boolean | Handles mouse click events |
| Switch:render | - | Renders the Switch |
Switch.new()
Returns
tableselfThe created instance
Switch:init(props, basalt)
Parameters
propstableThe properties to initialize the element withbasalttableThe basalt instance
Switch:mouse_click(button, x, y)
Parameters
buttonnumberThe button that was clickedxnumberThe x position of the clickynumberThe y position of the click
Returns
booleanWhetherthe event was handled