Skip to content

Commit 8c73572

Browse files
committed
Enhance documentation for ScrollFrame and TabControl elements with usage examples
1 parent fd67d0e commit 8c73572

2 files changed

Lines changed: 79 additions & 2 deletions

File tree

src/elements/ScrollFrame.lua

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,91 @@ local tHex = require("libraries/colorHex")
44
---@configDescription A scrollable container that automatically displays scrollbars when content overflows.
55

66
--- A container that provides automatic scrolling capabilities with visual scrollbars. Displays vertical and/or horizontal scrollbars when child content exceeds the container's dimensions.
7+
--- @run [[
8+
--- local basalt = require("basalt")
9+
---
10+
--- local main = basalt.getMainFrame()
11+
---
12+
--- -- Create a ScrollFrame with content larger than the frame
13+
--- local scrollFrame = main:addScrollFrame({
14+
--- x = 2,
15+
--- y = 2,
16+
--- width = 30,
17+
--- height = 12,
18+
--- background = colors.lightGray
19+
--- })
20+
---
21+
--- -- Add a title
22+
--- scrollFrame:addLabel({
23+
--- x = 2,
24+
--- y = 1,
25+
--- text = "ScrollFrame Example",
26+
--- foreground = colors.yellow
27+
--- })
28+
---
29+
--- -- Add multiple labels that exceed the frame height
30+
--- for i = 1, 20 do
31+
--- scrollFrame:addLabel({
32+
--- x = 2,
33+
--- y = i + 2,
34+
--- text = "Line " .. i .. " - Scroll to see more",
35+
--- foreground = i % 2 == 0 and colors.white or colors.lightGray
36+
--- })
37+
--- end
38+
---
39+
--- -- Add some interactive buttons at different positions
40+
--- scrollFrame:addButton({
41+
--- x = 2,
42+
--- y = 24,
43+
--- width = 15,
44+
--- height = 3,
45+
--- text = "Button 1",
46+
--- background = colors.blue
47+
--- })
48+
--- :onClick(function()
49+
--- scrollFrame:addLabel({
50+
--- x = 18,
51+
--- y = 24,
52+
--- text = "Clicked!",
53+
--- foreground = colors.lime
54+
--- })
55+
--- end)
56+
---
57+
--- scrollFrame:addButton({
58+
--- x = 2,
59+
--- y = 28,
60+
--- width = 15,
61+
--- height = 3,
62+
--- text = "Button 2",
63+
--- background = colors.green
64+
--- })
65+
--- :onClick(function()
66+
--- scrollFrame:addLabel({
67+
--- x = 18,
68+
--- y = 28,
69+
--- text = "Nice!",
70+
--- foreground = colors.orange
71+
--- })
72+
--- end)
73+
---
74+
--- -- Info label outside the scroll frame
75+
--- main:addLabel({
76+
--- x = 2,
77+
--- y = 15,
78+
--- text = "Use mouse wheel to scroll!",
79+
--- foreground = colors.gray
80+
--- })
81+
---
82+
--- basalt.run()
83+
--- ]]
784
---@class ScrollFrame : Container
885
local ScrollFrame = setmetatable({}, Container)
986
ScrollFrame.__index = ScrollFrame
1087

1188
---@property showScrollBar boolean true Whether to show scrollbars
1289
ScrollFrame.defineProperty(ScrollFrame, "showScrollBar", {default = true, type = "boolean", canTriggerRender = true})
1390

14-
---@property scrollBarSymbol string " " The symbol used for the scrollbar handle
91+
---@property scrollBarSymbol string "_" The symbol used for the scrollbar handle
1592
ScrollFrame.defineProperty(ScrollFrame, "scrollBarSymbol", {default = " ", type = "string", canTriggerRender = true})
1693

1794
---@property scrollBarBackground string "\127" The symbol used for the scrollbar background

src/elements/TabControl.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local log = require("log")
88
--- The TabControl is a container that provides tabbed interface functionality
99
--- @run [[
1010
--- local basalt = require("basalt")
11-
11+
---
1212
--- local main = basalt.getMainFrame()
1313
---
1414
--- -- Create a simple TabControl

0 commit comments

Comments
 (0)