Astrath:createCheckBox: Difference between revisions
Jump to navigation
Jump to search
(No difference)
|
Latest revision as of 19:40, 22 October 2025
DxCheckbox:new
Description: Creates a new DX-based checkbox element. Checkboxes can be attached to parent elements, support hover effects, custom colors, and selection state. Each checkbox instance is automatically registered in the DX library.
Parameters:
- text (string) – The label text of the checkbox. Defaults to "radio".
- posX, posY (float) – Position on screen.
- width, height (float) – Size of the checkbox.
- parent (element) – Parent DX element to attach this checkbox to (optional).
- relative (boolean) – Position relative to parent (optional).
- font (string) – Font used for text (optional, default: "default-bold").
- fontsize (float) – Font size multiplier (optional, default: 1).
Returns:
- Returns the newly created DxCheckbox element.
Methods:
Method | Description |
---|---|
Ath:destroy() | Destroys the checkbox and all its child elements. |
Ath:setVisible(boolean) | Shows or hides the checkbox. |
Ath:setEnabled(boolean) | Enables or disables the checkbox for interaction. |
Ath:isSelected() | Returns whether the checkbox is currently selected. |
Ath:setSelected(boolean) | Sets the checkbox selection state. |
Ath:getSelected() | Returns the current selection state. |
Ath:setHoverable(boolean) | Enables or disables hover effect. |
Ath:setColor(r, g, b, a, type) | Sets the main, hover, or select color of the checkbox. |
Example:
-- Create a checkbox at position 300x400 with size 20x20 local myCheckbox = DxCheckbox:new("Accept Terms", 300, 400, 20, 20) -- Show the checkbox and enable hover effect myCheckbox:setVisible(true) myCheckbox:setHoverable(true) -- Set selection state myCheckbox:setSelected(true) -- Change colors myCheckbox:setColor(255, 255, 255, 255, "mainColor") myCheckbox:setColor(0, 255, 0, 200, "hoverColor") myCheckbox:setColor(0, 200, 0, 255, "selectColor")
See also:
- Astrath – Main library page
- DxButton:new – Page for button element reference
- onClientRender – Event used to render DX elements