Skip to content

Commit add1d24

Browse files
committed
Fixed tab mouse click issue
1 parent 054bb8b commit add1d24

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

src/elements/DropDown.lua

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,62 @@ local tHex = require("libraries/colorHex")
55
---@configDescription A DropDown menu that shows a list of selectable items
66
---@configDefault false
77

8-
--- This is the DropDown class. It is a visual element that can show a list of selectable items in a DropDown menu.
9-
--- @usage local DropDown = main:addDropdown()
10-
--- @usage DropDown:setItems({
11-
--- @usage {text = "Item 1", callback = function() basalt.LOGGER.debug("Item 1 selected") end},
12-
--- @usage {text = "Item 2", callback = function() basalt.LOGGER.debug("Item 2 selected") end},
13-
--- @usage {text = "Item 3", callback = function() basalt.LOGGER.debug("Item 3 selected") end},
8+
--- Item Properties:
9+
--- Property|Type|Description
10+
--- -------|------|-------------
11+
--- text|string|The display text for the item
12+
--- separator|boolean|Makes item a divider line
13+
--- callback|function|Function called when selected
14+
--- foreground|color|Normal text color
15+
--- background|color|Normal background color
16+
--- selectedForeground|color|Text color when selected
17+
--- selectedBackground|color|Background when selected
18+
19+
--- A collapsible selection menu that expands to show multiple options when clicked. Supports single and multi-selection modes, custom item styling, separators, and item callbacks.
20+
--- @usage -- Create a styled dropdown menu
21+
--- @usage local dropdown = main:addDropDown()
22+
--- @usage :setPosition(5, 5)
23+
--- @usage :setSize(20, 1) -- Height expands when opened
24+
--- @usage :setSelectedText("Select an option...")
25+
--- @usage
26+
--- @usage -- Add items with different styles and callbacks
27+
--- @usage dropdown:setItems({
28+
--- @usage {
29+
--- @usage text = "Category A",
30+
--- @usage background = colors.blue,
31+
--- @usage foreground = colors.white
32+
--- @usage },
33+
--- @usage { separator = true, text = "-" }, -- Add a separator
34+
--- @usage {
35+
--- @usage text = "Option 1",
36+
--- @usage callback = function(self)
37+
--- @usage -- Handle selection
38+
--- @usage basalt.debug("Selected Option 1")
39+
--- @usage end
40+
--- @usage },
41+
--- @usage {
42+
--- @usage text = "Option 2",
43+
--- @usage -- Custom colors when selected
44+
--- @usage selectedBackground = colors.green,
45+
--- @usage selectedForeground = colors.white
46+
--- @usage }
1447
--- @usage })
48+
--- @usage
49+
--- @usage -- Listen for selections
50+
--- @usage dropdown:onChange(function(self, value)
51+
--- @usage basalt.debug("Selected:", value)
52+
--- @usage end)
1553
---@class DropDown : List
1654
local DropDown = setmetatable({}, List)
1755
DropDown.__index = DropDown
1856

19-
---@property isOpen boolean false Whether the DropDown menu is currently open
57+
---@property isOpen boolean false Controls the expanded/collapsed state
2058
DropDown.defineProperty(DropDown, "isOpen", {default = false, type = "boolean", canTriggerRender = true})
21-
---@property dropdownHeight number 5 Maximum height of the DropDown menu when open
59+
---@property dropdownHeight number 5 Maximum visible items when expanded
2260
DropDown.defineProperty(DropDown, "dropdownHeight", {default = 5, type = "number"})
23-
---@property selectedText string "" The text to show when no item is selected
61+
---@property selectedText string "" Text shown when no selection made
2462
DropDown.defineProperty(DropDown, "selectedText", {default = "", type = "string"})
25-
---@property dropSymbol string "\31" The symbol to show for DropDown indication
63+
---@property dropSymbol string "\31" Indicator for dropdown state
2664
DropDown.defineProperty(DropDown, "dropSymbol", {default = "\31", type = "string"})
2765

2866
--- Creates a new DropDown instance

src/elements/TabControl.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ TabControl.defineProperty(TabControl, "activeTabBackground", {default = colors.w
2626
---@property activeTabTextColor color Foreground color for the active tab text
2727
TabControl.defineProperty(TabControl, "activeTabTextColor", {default = colors.black, type = "color", canTriggerRender = true})
2828

29-
TabControl.defineEvent(TabControl, "tabChanged")
29+
TabControl.defineEvent(TabControl, "mouse_click")
30+
TabControl.defineEvent(TabControl, "mouse_up")
3031

3132
--- @shortDescription Creates a new TabControl instance
3233
--- @return TabControl self The created instance

0 commit comments

Comments
 (0)