3.8 KiB
3.8 KiB
TabControl
The TabControl is a container that provides tabbed interface functionality
Extends: Container
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| activeTab | number | The | currently active tab ID |
| tabHeight | number | Height | of the tab header area |
| tabs | table | List | of tab definitions |
| headerBackground | color | Background | color for the tab header area |
| activeTabBackground | color | Background | color for the active tab |
| activeTabTextColor | color | Foreground | color for the active tab text |
Functions
| Method | Returns | Description |
|---|---|---|
| TabControl.new | TabControl | Creates a new TabControl instance |
| TabControl:init | - | Initializes the TabControl instance |
| TabControl:newTab | table | Creates a new tab handler proxy |
| TabControl:setTab | TabControl | Sets an element to belong to a specific tab |
| TabControl:addElement | table | Adds an element to the TabControl and assigns it to the active tab |
| TabControl:addChild | Container | Overrides Container's addChild to assign new elements to tab 1 by default |
| TabControl:updateTabVisibility | - | Updates visibility of tab containers |
| TabControl:setActiveTab | - | Sets the active tab |
| TabControl:isChildVisible | boolean | Checks if a child should be visible (overrides Container) |
| TabControl:getContentYOffset | number | Gets the content area Y offset (below tab headers) |
| TabControl:mouse_click | boolean | Handles mouse click events for tab switching |
| TabControl:setCursor | - | Sets the cursor position; accounts for tab header offset when delegating to parent |
| TabControl:render | - | Renders the TabControl (header + children) |
| TabControl:sortChildrenEvents | - |
TabControl.new()
Returns
TabControlselfThe created instance
TabControl:init(props, basalt)
Parameters
propstableThe properties to initialize the element withbasalttableThe basalt instance
TabControl:newTab(title)
returns a proxy for adding elements to the tab
Parameters
titlestringThe title of the tab
Returns
tabletabHandlerThe tab handler proxy for adding elements to the new tab
TabControl:setTab(element, tabId)
Parameters
elementtableThe element to assign to a tabtabIdnumberThe ID of the tab to assign the element to
Returns
TabControlselfFor method chaining
TabControl:addElement(elementType, tabId)
Parameters
elementTypestringThe type of element to addtabIdnumberOptional tab ID, defaults to active tab
Returns
tableelementThe created element
TabControl:addChild(child)
Parameters
childtableThe child element to add
Returns
ContainerselfFor method chaining
TabControl:updateTabVisibility()
TabControl:setActiveTab(tabId)
Parameters
tabIdnumberThe ID of the tab to activate
TabControl:isChildVisible(child)
Parameters
childtableThe child element to check
Returns
booleanWhetherthe child should be visible
TabControl:getContentYOffset()
Returns
numberyOffsetThe Y offset for content
TabControl:mouse_click(button, x, y)
Parameters
buttonnumberThe button that was clickedxnumberThe x position of the click (global)ynumberThe y position of the click (global)
Returns
booleanWhetherthe event was handled