deploy: 167fc8ef81
This commit is contained in:
@@ -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
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
ElementManager.loadElement("Button")
|
||||
```
|
||||
|
||||
@@ -116,7 +116,7 @@ Checks if an element is loaded
|
||||
Clears the global cache (_G)
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
ElementManager.clearGlobalCache()
|
||||
```
|
||||
|
||||
|
||||
@@ -4,62 +4,62 @@ _A data visualization element that represents numeric data through vertical bars
|
||||
Extends: `Graph`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a bar chart
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local chart = main:addBarChart()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Add two data series with different colors
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addSeries("input", " ", colors.green, colors.green, 5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addSeries("output", " ", colors.red, colors.red, 5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Continuously update the chart with random data
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addPoint("input", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addPoint("output", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(2)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
@@ -4,71 +4,71 @@ _A specialized text element that renders characters in larger sizes using Wojbie
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a large welcome message
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local main = basalt.getMainFrame()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local title = main:addBigFont()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setPosition(3, 3)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setFontSize(2) -- Makes text twice as large
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setText("Welcome!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setForeground(colors.yellow) -- Make text yellow
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- For animated text
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
title:setForeground(colors.yellow)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(0.5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
title:setForeground(colors.orange)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(0.5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -4,83 +4,83 @@ _A clickable interface element that triggers actions when pressed. Supports text
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a simple action button
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local button = parent:addButton()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setPosition(5, 5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setText("Click me!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setBackground(colors.blue)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setForeground(colors.white)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Add click handling
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
button:onClick(function(self, button, x, y)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Change appearance when clicked
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
self:setBackground(colors.green)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
self:setText("Success!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Revert after delay
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(1)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
self:setBackground(colors.blue)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
self:setText("Click me!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -4,51 +4,51 @@ _A toggleable UI element that can be checked or unchecked. Displays different te
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a checkbox for a setting
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local checkbox = parent:addCheckBox()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setText("Enable Feature")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setCheckedText("✓")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:onChange("checked", function(self, checked)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- React to checkbox state changes
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
if checked then
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Handle enabled state
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
else
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Handle disabled state
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ Adds an item to the Collection
|
||||
* `Collection` `self` The Collection instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
Collection:addItem("New Item")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
Collection:addItem({text="Item", callback=function() end})
|
||||
```
|
||||
|
||||
@@ -62,7 +62,7 @@ Removes an item from the Collection
|
||||
* `Collection` `self` The Collection instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
Collection:removeItem(1)
|
||||
```
|
||||
|
||||
@@ -74,7 +74,7 @@ Clears all items from the Collection
|
||||
* `Collection` `self` The Collection instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
Collection:clear()
|
||||
```
|
||||
|
||||
@@ -86,7 +86,7 @@ Gets the currently selected items
|
||||
* `table` `selected` Collection of selected items
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
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
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
local index = Collection:getSelectedIndex()
|
||||
```
|
||||
|
||||
@@ -134,6 +134,6 @@ Registers a callback for the select event
|
||||
* `Collection` `self` The Collection instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
Collection:onSelect(function(index, item) print("Selected item:", index, item) end)
|
||||
```
|
||||
|
||||
@@ -5,75 +5,75 @@ _Supports auto-completion, custom styling, and both single and multi-selection m
|
||||
Extends: `DropDown`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a searchable country selector
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local combo = main:addComboBox()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setPosition(5, 5)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setSize(20, 1) -- Height will expand when opened
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setItems({
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
{text = "Germany"},
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
{text = "France"},
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
{text = "Spain"},
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
{text = "Italy"}
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
})
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setPlaceholder("Select country...")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setAutoComplete(true) -- Enable filtering while typing
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Handle selection changes
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
combo:onChange(function(self, value)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- value will be the selected country
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.debug("Selected:", value)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -10,87 +10,87 @@ _The Display maintains its own terminal buffer and can be manipulated using fami
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
-- Create a display for a custom terminal
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local display = main:addDisplay()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setSize(30, 10)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:setPosition(2, 2)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Get the window object for CC API operations
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local win = display:getWindow()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Use standard CC terminal operations
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
win.setTextColor(colors.yellow)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
win.setBackgroundColor(colors.blue)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
win.clear()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
win.setCursorPos(1, 1)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
win.write("Hello World!")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Or use the helper method
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
display:write(1, 2, "Direct write", colors.red, colors.black)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
-- Useful for external APIs
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
local paintutils = require("paintutils")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
paintutils.drawLine(1, 1, 10, 1, colors.red, win)
|
||||
```
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ _A collapsible selection menu that expands to show multiple options when clicked
|
||||
|
||||
Extends: `List`
|
||||
|
||||
## Usage
|
||||
## Examples (Executable)
|
||||
```lua run
|
||||
-- Create a styled dropdown menu
|
||||
local dropdown = main:addDropDown()
|
||||
|
||||
@@ -5,31 +5,31 @@ _The flexbox element adds the following properties to its children:_
|
||||
Extends: `Container`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local flex = main:addFlexbox({background=colors.black, width=30, height=10})
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
flex:addButton():setFlexGrow(1)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
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.
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
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.
|
||||
```
|
||||
|
||||
|
||||
@@ -4,47 +4,47 @@ _This is the base class for all graph elements. It is a point based graph._
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local graph = main:addGraph()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:addSeries("input", " ", colors.green, colors.green, 10)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:addSeries("output", " ", colors.red, colors.red, 10)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
graph:addPoint("input", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
graph:addPoint("output", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(2)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
|
||||
@@ -4,46 +4,46 @@ _The Line Chart element visualizes data series as connected line graphs. It plot
|
||||
Extends: `Graph`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local chart = main:addLineChart()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:addSeries("input", " ", colors.green, colors.green, 10)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
:addSeries("output", " ", colors.red, colors.red, 10)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.schedule(function()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
while true do
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addPoint("input", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
chart:addPoint("output", math.random(1,100))
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
sleep(2)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
end)
|
||||
```
|
||||
|
||||
@@ -42,7 +42,7 @@ Registers a callback for the select event
|
||||
* `List` `self` The List instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
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
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
list:scrollToItem(5)
|
||||
```
|
||||
|
||||
@@ -5,15 +5,15 @@ _with optional percentage display and customizable colors._
|
||||
Extends: `VisualElement`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local progressBar = main:addProgressBar()
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
progressBar:setDirection("up")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
progressBar:setProgress(50)
|
||||
```
|
||||
|
||||
|
||||
@@ -34,6 +34,6 @@ Gets the current value of the slider
|
||||
* `number` `value` The current value (0 to max)
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
local value = slider:getValue()
|
||||
```
|
||||
|
||||
@@ -4,15 +4,15 @@ _This is the table class. It provides a sortable data grid with customizable col
|
||||
Extends: `Collection`
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local people = container:addTable():setWidth(40)
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
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")
|
||||
```
|
||||
|
||||
@@ -66,7 +66,7 @@ Adds a new row to the table
|
||||
* `Table` `self` The Table instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
table:addRow("Alice", 30, "USA")
|
||||
```
|
||||
|
||||
@@ -150,7 +150,7 @@ Set data with automatic formatting
|
||||
* `Table` `self` The Table instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
table:setData({{...}}, {[1] = tostring, [2] = function(age) return age.."y" end})
|
||||
```
|
||||
|
||||
|
||||
@@ -15,6 +15,6 @@ Handles an error
|
||||
* `errMsg` `string` The error message
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
errorHandler.error("An error occurred")
|
||||
```
|
||||
|
||||
@@ -25,7 +25,7 @@ Sets if the logger should log
|
||||
Sends a debug message to the logger.
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
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.
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
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.
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
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.
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
Log.error("This is an error message")
|
||||
```
|
||||
|
||||
@@ -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"._
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
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
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
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
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
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
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
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)
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
basalt.requireElements({"Button", "Label", "Slider"})
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.requireElements("Button", true)
|
||||
```
|
||||
|
||||
@@ -232,7 +232,7 @@ Loads a manifest file that describes element requirements and configuration
|
||||
* `table` `manifest` The loaded manifest data
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
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
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
basalt.install("Slider")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
basalt.install("Slider", "https://example.com/slider.lua")
|
||||
```
|
||||
|
||||
@@ -261,6 +261,6 @@ Configures the ElementManager (shortcut to elementManager.configure)
|
||||
* `config` `table` Configuration options
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
basalt.configure({allowRemoteLoading = true, useGlobalCache = true})
|
||||
```
|
||||
|
||||
@@ -74,7 +74,7 @@ Registers a new animation type
|
||||
* `handlers` `table` Table containing start, update and complete handlers
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
Animation.registerAnimation("fade", {start=function(anim) end, update=function(anim,progress) end})
|
||||
```
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ Enables benchmarking for a method
|
||||
* `BaseElement` `self` The element instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
element:benchmark("render")
|
||||
```
|
||||
|
||||
@@ -99,7 +99,7 @@ Enables benchmarking for a container and all its children
|
||||
* `Container` `self` The container instance
|
||||
|
||||
### Usage
|
||||
```lua run
|
||||
```lua
|
||||
container:benchmarkContainer("render")
|
||||
```
|
||||
|
||||
|
||||
@@ -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._
|
||||
|
||||
## Usage
|
||||
```lua run
|
||||
```lua
|
||||
local button = main:addButton({text="Exit"})
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
button:setX("{parent.x - 12}")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
button:setBackground("{self.clicked and colors.red or colors.green}")
|
||||
```
|
||||
|
||||
```lua run
|
||||
```lua
|
||||
button:setWidth("{#self.text + 2}")
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user