Astrath:createComboBox: Difference between revisions
Jump to navigation
Jump to search
(Created page with "= DxCombobox:new / Astrath:createCombobox = {{Client function}} {{FuncDef|element DxCombobox:new ( string text, float posX, float posY, float width, float height, element parent, boolean relative, string desc, number maxItems, table color, string font, float fontSize, table scrollColor, table scrollBGColor )}} '''Description:''' Creates a new DX-based combobox element. Comboboxes allow selecting from a list of items, support scrolling, hover effects, and color customiz...") |
|||
Line 1: | Line 1: | ||
= DxCombobox:new | = DxCombobox:new = | ||
{{Client function}} | {{Client function}} | ||
Line 38: | Line 38: | ||
|- | |- | ||
| Ath:removeItem(number) || Removes an item from the list by its index. | | Ath:removeItem(number) || Removes an item from the list by its index. | ||
|- | |- | ||
| Ath:clear() || Removes all items from the combobox. | | Ath:clear() || Removes all items from the combobox. |
Latest revision as of 19:44, 22 October 2025
DxCombobox:new
Description: Creates a new DX-based combobox element. Comboboxes allow selecting from a list of items, support scrolling, hover effects, and color customization. Each combobox instance is automatically registered in the DX library.
Parameters:
- text (string) – The default text displayed on the combobox.
- posX, posY (float) – Position on screen.
- width, height (float) – Size of the combobox.
- parent (element) – Parent DX element to attach this combobox to (optional).
- relative (boolean) – Position relative to parent (optional).
- desc (string) – Default placeholder text when no item is selected (optional).
- maxItems (number) – Maximum number of items displayed at once (optional, default: 10).
- color (table / tocolor) – Base color for bar, button, and body (optional).
- font (string) – Font used for text (optional, default: "default-bold").
- fontSize (float) – Font size multiplier (optional, default: 1).
- scrollColor, scrollBGColor (table / tocolor) – Scrollbar colors (optional).
Returns:
- Returns the newly created DxCombobox element.
Methods:
Method | Description |
---|---|
Ath:destroy() | Destroys the combobox and all its child elements. |
Ath:setVisible(boolean) | Shows or hides the combobox. |
Ath:setEnabled(boolean) | Enables or disables the combobox for interaction. |
Ath:setText(string) | Sets the text displayed on the combobox. |
Ath:addItem(string) | Adds a new item to the combobox list. |
Ath:removeItem(number) | Removes an item from the list by its index. |
Ath:clear() | Removes all items from the combobox. |
Ath:setItemText(number, string) | Updates the text of an item at a given index. |
Ath:getItemText(number) | Returns the text of an item by index. |
Ath:setSelected(number) | Sets the selected item by index. |
Ath:getSelected() | Returns the index of the currently selected item. |
Ath:getItemCount() | Returns the total number of items in the combobox. |
Ath:setHoverable(boolean) | Enables or disables hover effect. |
Ath:setColor(r, g, b, a, type) | Sets the color of bar, button, body, or hover. |
Example:
-- Create a combobox at position 400x200 with size 150x25 local myCombo = DxCombobox:new("Select Item", 400, 200, 150, 25) -- Add items myCombo:addItem("Option 1") myCombo:addItem("Option 2") myCombo:addItem("Option 3") -- Show combobox and enable hover myCombo:setVisible(true) myCombo:setHoverable(true) -- Select second item myCombo:setSelected(2) -- Change bar color myCombo:setColor(255, 255, 255, 255, "barColor")
See also:
- Astrath – Main library page
- DxButton:new – Page for button element reference
- DxCheckbox:new – Page for checkbox element reference
- onClientRender – Event used to render DX elements