This commit is contained in:
NoryiE
2025-10-29 17:18:10 +00:00
parent 00a9ce5632
commit c9bdfc6a69
22 changed files with 175 additions and 175 deletions

View File

@@ -60,7 +60,7 @@ Loads an element by name. This will load the element and apply any plugins to it
* `name` `string` The name of the element to load * `name` `string` The name of the element to load
### Usage ### Usage
```lua run ```lua
ElementManager.loadElement("Button") ElementManager.loadElement("Button")
``` ```
@@ -116,7 +116,7 @@ Checks if an element is loaded
Clears the global cache (_G) Clears the global cache (_G)
### Usage ### Usage
```lua run ```lua
ElementManager.clearGlobalCache() ElementManager.clearGlobalCache()
``` ```

View File

@@ -4,62 +4,62 @@ _A data visualization element that represents numeric data through vertical bars
Extends: `Graph` Extends: `Graph`
## Usage ## Usage
```lua run ```lua
-- Create a bar chart -- Create a bar chart
``` ```
```lua run ```lua
local chart = main:addBarChart() local chart = main:addBarChart()
``` ```
```lua run ```lua
``` ```
```lua run ```lua
-- Add two data series with different colors -- Add two data series with different colors
``` ```
```lua run ```lua
chart:addSeries("input", " ", colors.green, colors.green, 5) chart:addSeries("input", " ", colors.green, colors.green, 5)
``` ```
```lua run ```lua
chart:addSeries("output", " ", colors.red, colors.red, 5) chart:addSeries("output", " ", colors.red, colors.red, 5)
``` ```
```lua run ```lua
``` ```
```lua run ```lua
-- Continuously update the chart with random data -- Continuously update the chart with random data
``` ```
```lua run ```lua
basalt.schedule(function() basalt.schedule(function()
``` ```
```lua run ```lua
while true do while true do
``` ```
```lua run ```lua
chart:addPoint("input", math.random(1,100)) chart:addPoint("input", math.random(1,100))
``` ```
```lua run ```lua
chart:addPoint("output", math.random(1,100)) chart:addPoint("output", math.random(1,100))
``` ```
```lua run ```lua
sleep(2) sleep(2)
``` ```
```lua run ```lua
end end
``` ```
```lua run ```lua
end) end)
``` ```

View File

@@ -4,71 +4,71 @@ _A specialized text element that renders characters in larger sizes using Wojbie
Extends: `VisualElement` Extends: `VisualElement`
## Usage ## Usage
```lua run ```lua
-- Create a large welcome message -- Create a large welcome message
``` ```
```lua run ```lua
local main = basalt.getMainFrame() local main = basalt.getMainFrame()
``` ```
```lua run ```lua
local title = main:addBigFont() local title = main:addBigFont()
``` ```
```lua run ```lua
:setPosition(3, 3) :setPosition(3, 3)
``` ```
```lua run ```lua
:setFontSize(2) -- Makes text twice as large :setFontSize(2) -- Makes text twice as large
``` ```
```lua run ```lua
:setText("Welcome!") :setText("Welcome!")
``` ```
```lua run ```lua
:setForeground(colors.yellow) -- Make text yellow :setForeground(colors.yellow) -- Make text yellow
``` ```
```lua run ```lua
``` ```
```lua run ```lua
-- For animated text -- For animated text
``` ```
```lua run ```lua
basalt.schedule(function() basalt.schedule(function()
``` ```
```lua run ```lua
while true do while true do
``` ```
```lua run ```lua
title:setForeground(colors.yellow) title:setForeground(colors.yellow)
``` ```
```lua run ```lua
sleep(0.5) sleep(0.5)
``` ```
```lua run ```lua
title:setForeground(colors.orange) title:setForeground(colors.orange)
``` ```
```lua run ```lua
sleep(0.5) sleep(0.5)
``` ```
```lua run ```lua
end end
``` ```
```lua run ```lua
end) end)
``` ```

View File

@@ -4,83 +4,83 @@ _A clickable interface element that triggers actions when pressed. Supports text
Extends: `VisualElement` Extends: `VisualElement`
## Usage ## Usage
```lua run ```lua
-- Create a simple action button -- Create a simple action button
``` ```
```lua run ```lua
local button = parent:addButton() local button = parent:addButton()
``` ```
```lua run ```lua
:setPosition(5, 5) :setPosition(5, 5)
``` ```
```lua run ```lua
:setText("Click me!") :setText("Click me!")
``` ```
```lua run ```lua
:setBackground(colors.blue) :setBackground(colors.blue)
``` ```
```lua run ```lua
:setForeground(colors.white) :setForeground(colors.white)
``` ```
```lua run ```lua
``` ```
```lua run ```lua
-- Add click handling -- Add click handling
``` ```
```lua run ```lua
button:onClick(function(self, button, x, y) button:onClick(function(self, button, x, y)
``` ```
```lua run ```lua
-- Change appearance when clicked -- Change appearance when clicked
``` ```
```lua run ```lua
self:setBackground(colors.green) self:setBackground(colors.green)
``` ```
```lua run ```lua
self:setText("Success!") self:setText("Success!")
``` ```
```lua run ```lua
``` ```
```lua run ```lua
-- Revert after delay -- Revert after delay
``` ```
```lua run ```lua
basalt.schedule(function() basalt.schedule(function()
``` ```
```lua run ```lua
sleep(1) sleep(1)
``` ```
```lua run ```lua
self:setBackground(colors.blue) self:setBackground(colors.blue)
``` ```
```lua run ```lua
self:setText("Click me!") self:setText("Click me!")
``` ```
```lua run ```lua
end) end)
``` ```
```lua run ```lua
end) end)
``` ```

View File

@@ -4,51 +4,51 @@ _A toggleable UI element that can be checked or unchecked. Displays different te
Extends: `VisualElement` Extends: `VisualElement`
## Usage ## Usage
```lua run ```lua
-- Create a checkbox for a setting -- Create a checkbox for a setting
``` ```
```lua run ```lua
local checkbox = parent:addCheckBox() local checkbox = parent:addCheckBox()
``` ```
```lua run ```lua
:setText("Enable Feature") :setText("Enable Feature")
``` ```
```lua run ```lua
:setCheckedText("✓") :setCheckedText("✓")
``` ```
```lua run ```lua
:onChange("checked", function(self, checked) :onChange("checked", function(self, checked)
``` ```
```lua run ```lua
-- React to checkbox state changes -- React to checkbox state changes
``` ```
```lua run ```lua
if checked then if checked then
``` ```
```lua run ```lua
-- Handle enabled state -- Handle enabled state
``` ```
```lua run ```lua
else else
``` ```
```lua run ```lua
-- Handle disabled state -- Handle disabled state
``` ```
```lua run ```lua
end end
``` ```
```lua run ```lua
end) end)
``` ```

View File

@@ -43,11 +43,11 @@ Adds an item to the Collection
* `Collection` `self` The Collection instance * `Collection` `self` The Collection instance
### Usage ### Usage
```lua run ```lua
Collection:addItem("New Item") Collection:addItem("New Item")
``` ```
```lua run ```lua
Collection:addItem({text="Item", callback=function() end}) Collection:addItem({text="Item", callback=function() end})
``` ```
@@ -62,7 +62,7 @@ Removes an item from the Collection
* `Collection` `self` The Collection instance * `Collection` `self` The Collection instance
### Usage ### Usage
```lua run ```lua
Collection:removeItem(1) Collection:removeItem(1)
``` ```
@@ -74,7 +74,7 @@ Clears all items from the Collection
* `Collection` `self` The Collection instance * `Collection` `self` The Collection instance
### Usage ### Usage
```lua run ```lua
Collection:clear() Collection:clear()
``` ```
@@ -86,7 +86,7 @@ Gets the currently selected items
* `table` `selected` Collection of selected items * `table` `selected` Collection of selected items
### Usage ### Usage
```lua run ```lua
local selected = Collection:getSelectedItems() local selected = Collection:getSelectedItems()
``` ```
@@ -105,7 +105,7 @@ Gets the index of the first selected item
* `index` `The` index of the first selected item, or nil if none selected * `index` `The` index of the first selected item, or nil if none selected
### Usage ### Usage
```lua run ```lua
local index = Collection:getSelectedIndex() local index = Collection:getSelectedIndex()
``` ```
@@ -134,6 +134,6 @@ Registers a callback for the select event
* `Collection` `self` The Collection instance * `Collection` `self` The Collection instance
### Usage ### Usage
```lua run ```lua
Collection:onSelect(function(index, item) print("Selected item:", index, item) end) Collection:onSelect(function(index, item) print("Selected item:", index, item) end)
``` ```

View File

@@ -5,75 +5,75 @@ _Supports auto-completion, custom styling, and both single and multi-selection m
Extends: `DropDown` Extends: `DropDown`
## Usage ## Usage
```lua run ```lua
-- Create a searchable country selector -- Create a searchable country selector
``` ```
```lua run ```lua
local combo = main:addComboBox() local combo = main:addComboBox()
``` ```
```lua run ```lua
:setPosition(5, 5) :setPosition(5, 5)
``` ```
```lua run ```lua
:setSize(20, 1) -- Height will expand when opened :setSize(20, 1) -- Height will expand when opened
``` ```
```lua run ```lua
:setItems({ :setItems({
``` ```
```lua run ```lua
{text = "Germany"}, {text = "Germany"},
``` ```
```lua run ```lua
{text = "France"}, {text = "France"},
``` ```
```lua run ```lua
{text = "Spain"}, {text = "Spain"},
``` ```
```lua run ```lua
{text = "Italy"} {text = "Italy"}
``` ```
```lua run ```lua
}) })
``` ```
```lua run ```lua
:setPlaceholder("Select country...") :setPlaceholder("Select country...")
``` ```
```lua run ```lua
:setAutoComplete(true) -- Enable filtering while typing :setAutoComplete(true) -- Enable filtering while typing
``` ```
```lua run ```lua
``` ```
```lua run ```lua
-- Handle selection changes -- Handle selection changes
``` ```
```lua run ```lua
combo:onChange(function(self, value) combo:onChange(function(self, value)
``` ```
```lua run ```lua
-- value will be the selected country -- value will be the selected country
``` ```
```lua run ```lua
basalt.debug("Selected:", value) basalt.debug("Selected:", value)
``` ```
```lua run ```lua
end) end)
``` ```

View File

@@ -10,87 +10,87 @@ _The Display maintains its own terminal buffer and can be manipulated using fami
Extends: `VisualElement` Extends: `VisualElement`
## Usage ## Usage
```lua run ```lua
-- Create a display for a custom terminal -- Create a display for a custom terminal
``` ```
```lua run ```lua
local display = main:addDisplay() local display = main:addDisplay()
``` ```
```lua run ```lua
:setSize(30, 10) :setSize(30, 10)
``` ```
```lua run ```lua
:setPosition(2, 2) :setPosition(2, 2)
``` ```
```lua run ```lua
``` ```
```lua run ```lua
-- Get the window object for CC API operations -- Get the window object for CC API operations
``` ```
```lua run ```lua
local win = display:getWindow() local win = display:getWindow()
``` ```
```lua run ```lua
``` ```
```lua run ```lua
-- Use standard CC terminal operations -- Use standard CC terminal operations
``` ```
```lua run ```lua
win.setTextColor(colors.yellow) win.setTextColor(colors.yellow)
``` ```
```lua run ```lua
win.setBackgroundColor(colors.blue) win.setBackgroundColor(colors.blue)
``` ```
```lua run ```lua
win.clear() win.clear()
``` ```
```lua run ```lua
win.setCursorPos(1, 1) win.setCursorPos(1, 1)
``` ```
```lua run ```lua
win.write("Hello World!") win.write("Hello World!")
``` ```
```lua run ```lua
``` ```
```lua run ```lua
-- Or use the helper method -- Or use the helper method
``` ```
```lua run ```lua
display:write(1, 2, "Direct write", colors.red, colors.black) display:write(1, 2, "Direct write", colors.red, colors.black)
``` ```
```lua run ```lua
``` ```
```lua run ```lua
-- Useful for external APIs -- Useful for external APIs
``` ```
```lua run ```lua
local paintutils = require("paintutils") local paintutils = require("paintutils")
``` ```
```lua run ```lua
paintutils.drawLine(1, 1, 10, 1, colors.red, win) paintutils.drawLine(1, 1, 10, 1, colors.red, win)
``` ```

View File

@@ -3,7 +3,7 @@ _A collapsible selection menu that expands to show multiple options when clicked
Extends: `List` Extends: `List`
## Usage ## Examples (Executable)
```lua run ```lua run
-- Create a styled dropdown menu -- Create a styled dropdown menu
local dropdown = main:addDropDown() local dropdown = main:addDropDown()

View File

@@ -5,31 +5,31 @@ _The flexbox element adds the following properties to its children:_
Extends: `Container` Extends: `Container`
## Usage ## Usage
```lua run ```lua
local flex = main:addFlexbox({background=colors.black, width=30, height=10}) local flex = main:addFlexbox({background=colors.black, width=30, height=10})
``` ```
```lua run ```lua
flex:addButton():setFlexGrow(1) flex:addButton():setFlexGrow(1)
``` ```
```lua run ```lua
flex:addButton():setFlexGrow(1) flex:addButton():setFlexGrow(1)
``` ```
```lua run ```lua
flex:addButton():setFlexGrow(1) flex:addButton():setFlexGrow(1)
``` ```
```lua run ```lua
flex:addButton():setFlexGrow(1) -- The flex-grow property defines the ability for a flex item to grow if necessary. flex:addButton():setFlexGrow(1) -- The flex-grow property defines the ability for a flex item to grow if necessary.
``` ```
```lua run ```lua
flex:addButton():setFlexShrink(1) -- The flex-shrink property defines the ability for a flex item to shrink if necessary. flex:addButton():setFlexShrink(1) -- The flex-shrink property defines the ability for a flex item to shrink if necessary.
``` ```
```lua run ```lua
flex:addButton():setFlexBasis(1) -- The flex-basis property defines the default size of an element before the remaining space is distributed. flex:addButton():setFlexBasis(1) -- The flex-basis property defines the default size of an element before the remaining space is distributed.
``` ```

View File

@@ -4,47 +4,47 @@ _This is the base class for all graph elements. It is a point based graph._
Extends: `VisualElement` Extends: `VisualElement`
## Usage ## Usage
```lua run ```lua
local graph = main:addGraph() local graph = main:addGraph()
``` ```
```lua run ```lua
:addSeries("input", " ", colors.green, colors.green, 10) :addSeries("input", " ", colors.green, colors.green, 10)
``` ```
```lua run ```lua
:addSeries("output", " ", colors.red, colors.red, 10) :addSeries("output", " ", colors.red, colors.red, 10)
``` ```
```lua run ```lua
``` ```
```lua run ```lua
basalt.schedule(function() basalt.schedule(function()
``` ```
```lua run ```lua
while true do while true do
``` ```
```lua run ```lua
graph:addPoint("input", math.random(1,100)) graph:addPoint("input", math.random(1,100))
``` ```
```lua run ```lua
graph:addPoint("output", math.random(1,100)) graph:addPoint("output", math.random(1,100))
``` ```
```lua run ```lua
sleep(2) sleep(2)
``` ```
```lua run ```lua
end end
``` ```
```lua run ```lua
end) end)
``` ```

View File

@@ -4,46 +4,46 @@ _The Line Chart element visualizes data series as connected line graphs. It plot
Extends: `Graph` Extends: `Graph`
## Usage ## Usage
```lua run ```lua
local chart = main:addLineChart() local chart = main:addLineChart()
``` ```
```lua run ```lua
:addSeries("input", " ", colors.green, colors.green, 10) :addSeries("input", " ", colors.green, colors.green, 10)
``` ```
```lua run ```lua
:addSeries("output", " ", colors.red, colors.red, 10) :addSeries("output", " ", colors.red, colors.red, 10)
``` ```
```lua run ```lua
``` ```
```lua run ```lua
basalt.schedule(function() basalt.schedule(function()
``` ```
```lua run ```lua
while true do while true do
``` ```
```lua run ```lua
chart:addPoint("input", math.random(1,100)) chart:addPoint("input", math.random(1,100))
``` ```
```lua run ```lua
chart:addPoint("output", math.random(1,100)) chart:addPoint("output", math.random(1,100))
``` ```
```lua run ```lua
sleep(2) sleep(2)
``` ```
```lua run ```lua
end end
``` ```
```lua run ```lua
end) end)
``` ```

View File

@@ -42,7 +42,7 @@ Registers a callback for the select event
* `List` `self` The List instance * `List` `self` The List instance
### Usage ### Usage
```lua run ```lua
list:onSelect(function(index, item) print("Selected item:", index, item) end) list:onSelect(function(index, item) print("Selected item:", index, item) end)
``` ```
@@ -71,6 +71,6 @@ Scrolls to make a specific item visible
* `List` `self` The List instance * `List` `self` The List instance
### Usage ### Usage
```lua run ```lua
list:scrollToItem(5) list:scrollToItem(5)
``` ```

View File

@@ -5,15 +5,15 @@ _with optional percentage display and customizable colors._
Extends: `VisualElement` Extends: `VisualElement`
## Usage ## Usage
```lua run ```lua
local progressBar = main:addProgressBar() local progressBar = main:addProgressBar()
``` ```
```lua run ```lua
progressBar:setDirection("up") progressBar:setDirection("up")
``` ```
```lua run ```lua
progressBar:setProgress(50) progressBar:setProgress(50)
``` ```

View File

@@ -34,6 +34,6 @@ Gets the current value of the slider
* `number` `value` The current value (0 to max) * `number` `value` The current value (0 to max)
### Usage ### Usage
```lua run ```lua
local value = slider:getValue() local value = slider:getValue()
``` ```

View File

@@ -4,15 +4,15 @@ _This is the table class. It provides a sortable data grid with customizable col
Extends: `Collection` Extends: `Collection`
## Usage ## Usage
```lua run ```lua
local people = container:addTable():setWidth(40) local people = container:addTable():setWidth(40)
``` ```
```lua run ```lua
people:setColumns({{name="Name",width=12}, {name="Age",width=10}, {name="Country",width=15}}) people:setColumns({{name="Name",width=12}, {name="Age",width=10}, {name="Country",width=15}})
``` ```
```lua run ```lua
people:addRow("Alice", 30, "USA"):addRow("Bob", 25, "UK") people:addRow("Alice", 30, "USA"):addRow("Bob", 25, "UK")
``` ```
@@ -66,7 +66,7 @@ Adds a new row to the table
* `Table` `self` The Table instance * `Table` `self` The Table instance
### Usage ### Usage
```lua run ```lua
table:addRow("Alice", 30, "USA") table:addRow("Alice", 30, "USA")
``` ```
@@ -150,7 +150,7 @@ Set data with automatic formatting
* `Table` `self` The Table instance * `Table` `self` The Table instance
### Usage ### Usage
```lua run ```lua
table:setData({{...}}, {[1] = tostring, [2] = function(age) return age.."y" end}) table:setData({{...}}, {[1] = tostring, [2] = function(age) return age.."y" end})
``` ```

View File

@@ -15,6 +15,6 @@ Handles an error
* `errMsg` `string` The error message * `errMsg` `string` The error message
### Usage ### Usage
```lua run ```lua
errorHandler.error("An error occurred") errorHandler.error("An error occurred")
``` ```

View File

@@ -25,7 +25,7 @@ Sets if the logger should log
Sends a debug message to the logger. Sends a debug message to the logger.
### Usage ### Usage
```lua run ```lua
Log.debug("This is a debug message") Log.debug("This is a debug message")
``` ```
@@ -34,7 +34,7 @@ Log.debug("This is a debug message")
Sends an info message to the logger. Sends an info message to the logger.
### Usage ### Usage
```lua run ```lua
Log.info("This is an info message") Log.info("This is an info message")
``` ```
@@ -43,7 +43,7 @@ Log.info("This is an info message")
Sends a warning message to the logger. Sends a warning message to the logger.
### Usage ### Usage
```lua run ```lua
Log.warn("This is a warning message") Log.warn("This is a warning message")
``` ```
@@ -52,6 +52,6 @@ Log.warn("This is a warning message")
Sends an error message to the logger. Sends an error message to the logger.
### Usage ### Usage
```lua run ```lua
Log.error("This is an error message") Log.error("This is an error message")
``` ```

View File

@@ -5,7 +5,7 @@ _Before you can access Basalt, you need to add the following code on top of your
_What this code does is it loads basalt into the project, and you can access it by using the variable defined as "basalt"._ _What this code does is it loads basalt into the project, and you can access it by using the variable defined as "basalt"._
## Usage ## Usage
```lua run ```lua
local basalt = require("basalt") local basalt = require("basalt")
``` ```
@@ -49,7 +49,7 @@ Creates and returns a new UI element of the specified type.
* `table` `element` The created element instance * `table` `element` The created element instance
### Usage ### Usage
```lua run ```lua
local button = basalt.create("Button") local button = basalt.create("Button")
``` ```
@@ -177,7 +177,7 @@ Registers a callback function for a specific event
* `callback` `function` The callback function to execute when the event occurs * `callback` `function` The callback function to execute when the event occurs
### Usage ### Usage
```lua run ```lua
basalt.onEvent("mouse_click", function(button, x, y) basalt.debug("Clicked at", x, y) end) basalt.onEvent("mouse_click", function(button, x, y) basalt.debug("Clicked at", x, y) end)
``` ```
@@ -200,7 +200,7 @@ Triggers a custom event and calls all registered callbacks
* `eventName` `string` The name of the event to trigger * `eventName` `string` The name of the event to trigger
### Usage ### Usage
```lua run ```lua
basalt.triggerEvent("custom_event", "data1", "data2") basalt.triggerEvent("custom_event", "data1", "data2")
``` ```
@@ -213,11 +213,11 @@ Requires specific elements and validates they are available
* `autoLoad` *(optional)* `boolean` Whether to automatically load missing elements (default: false) * `autoLoad` *(optional)* `boolean` Whether to automatically load missing elements (default: false)
### Usage ### Usage
```lua run ```lua
basalt.requireElements({"Button", "Label", "Slider"}) basalt.requireElements({"Button", "Label", "Slider"})
``` ```
```lua run ```lua
basalt.requireElements("Button", true) basalt.requireElements("Button", true)
``` ```
@@ -232,7 +232,7 @@ Loads a manifest file that describes element requirements and configuration
* `table` `manifest` The loaded manifest data * `table` `manifest` The loaded manifest data
### Usage ### Usage
```lua run ```lua
basalt.loadManifest("myapp.manifest") basalt.loadManifest("myapp.manifest")
``` ```
@@ -245,11 +245,11 @@ Installs an element interactively or from a specified source
* `source` *(optional)* `string` Optional source URL or path * `source` *(optional)* `string` Optional source URL or path
### Usage ### Usage
```lua run ```lua
basalt.install("Slider") basalt.install("Slider")
``` ```
```lua run ```lua
basalt.install("Slider", "https://example.com/slider.lua") basalt.install("Slider", "https://example.com/slider.lua")
``` ```
@@ -261,6 +261,6 @@ Configures the ElementManager (shortcut to elementManager.configure)
* `config` `table` Configuration options * `config` `table` Configuration options
### Usage ### Usage
```lua run ```lua
basalt.configure({allowRemoteLoading = true, useGlobalCache = true}) basalt.configure({allowRemoteLoading = true, useGlobalCache = true})
``` ```

View File

@@ -74,7 +74,7 @@ Registers a new animation type
* `handlers` `table` Table containing start, update and complete handlers * `handlers` `table` Table containing start, update and complete handlers
### Usage ### Usage
```lua run ```lua
Animation.registerAnimation("fade", {start=function(anim) end, update=function(anim,progress) end}) Animation.registerAnimation("fade", {start=function(anim) end, update=function(anim,progress) end})
``` ```

View File

@@ -42,7 +42,7 @@ Enables benchmarking for a method
* `BaseElement` `self` The element instance * `BaseElement` `self` The element instance
### Usage ### Usage
```lua run ```lua
element:benchmark("render") element:benchmark("render")
``` ```
@@ -99,7 +99,7 @@ Enables benchmarking for a container and all its children
* `Container` `self` The container instance * `Container` `self` The container instance
### Usage ### Usage
```lua run ```lua
container:benchmarkContainer("render") container:benchmarkContainer("render")
``` ```

View File

@@ -3,18 +3,18 @@ _This module provides reactive functionality for elements, it adds no new functi
_It is used to evaluate expressions in property values and update the element when the expression changes._ _It is used to evaluate expressions in property values and update the element when the expression changes._
## Usage ## Usage
```lua run ```lua
local button = main:addButton({text="Exit"}) local button = main:addButton({text="Exit"})
``` ```
```lua run ```lua
button:setX("{parent.x - 12}") button:setX("{parent.x - 12}")
``` ```
```lua run ```lua
button:setBackground("{self.clicked and colors.red or colors.green}") button:setBackground("{self.clicked and colors.red or colors.green}")
``` ```
```lua run ```lua
button:setWidth("{#self.text + 2}") button:setWidth("{#self.text + 2}")
``` ```