Astrath:createTab: Difference between revisions
Jump to navigation
Jump to search
(Created page with "= DxTab:new = {{Client function}} {{FuncDef|element DxTab:new ( element parent, string text, table color, table hoverColor, table activeColor, table tabColor )}} '''Description:''' Creates a new tab element inside a `DxTabPanel`. Tabs are linked to a panel and their positions are automatically managed according to the panel layout. Only usable with a valid `DxTabPanel` parent. '''Parameters:''' * parent (element) – A `DxTabPanel` element where this tab will be attac...") |
(No difference)
|
Revision as of 20:23, 22 October 2025
DxTab:new
Description: Creates a new tab element inside a `DxTabPanel`. Tabs are linked to a panel and their positions are automatically managed according to the panel layout. Only usable with a valid `DxTabPanel` parent.
Parameters:
- parent (element) – A `DxTabPanel` element where this tab will be attached (required).
- text (string) – The text to display on the tab (optional, default: 'tab').
- color (table / tocolor) – The main color of the tab (optional, defaults to parent's color).
- hoverColor (table / tocolor) – Color when hovering (optional, defaults to parent's hoverColor).
- activeColor (table / tocolor) – Color when tab is active (optional, defaults to parent's activeColor).
- tabColor (table / tocolor) – Base color for inactive tabs (optional, defaults to parent's tabColor).
Returns:
- Returns the newly created `DxTab` element.
Methods:
Method | Description |
---|---|
Ath:destroy() | Destroys the tab and removes it from the parent panel. |
Ath:setVisible(boolean) | Shows or hides the tab and triggers reordering in the panel. |
Ath:setEnabled(boolean) | Enables or disables the tab. |
Ath:setHoverable(boolean) | Enables or disables hover effects for this tab. |
Ath:setColor(r, g, b, a, type) | Sets the tab's color. Type can be 'mainColor', 'hoverColor', 'tabColor', 'activeColor'. |
Example:
-- Crear un tab panel local tabPanel = DxTabPanel:new(100, 100, 400, 300) tabPanel:setVisible(true) -- Agregar tabs local tab1 = DxTab:new(tabPanel, "Tab 1") local tab2 = DxTab:new(tabPanel, "Tab 2", tocolor(200,0,0,255)) -- Establecer tab seleccionado tabPanel:setSelected(tab1) -- Dibujar panel y tabs en el evento onClientRender addEventHandler("onClientRender", root, function() tabPanel:draw() for i, tab in ipairs(tabPanel.children) do tab:draw() end end)
See also:
- DxTabPanel:new – The panel container required for tabs
- onClientRender – Event used to draw DX elements each frame
- adjustAlpha – Function used internally to adjust tab opacity