This commit is contained in:
NoryiE
2025-02-24 19:52:39 +00:00
parent eecb6e9dc1
commit 5513bf4072
14 changed files with 409 additions and 138 deletions

View File

@@ -1,5 +1,5 @@
# BaseElement : PropertySystem # BaseElement : PropertySystem
The base class for all UI elements in Basalt The base class for all UI elements in Basalt. This class provides basic properties and event handling functionality.
## Properties ## Properties

View File

@@ -21,11 +21,9 @@ This is the base frame class. It is the root element of all elements and the onl
|[BaseFrame.new](#BaseFrame.new)|BaseFrame|Creates a new Frame instance |[BaseFrame.new](#BaseFrame.new)|BaseFrame|Creates a new Frame instance
|[BaseFrame:blit](#BaseFrame:blit)|-|Renders a text with a foreground and background color to the render Object |[BaseFrame:blit](#BaseFrame:blit)|-|Renders a text with a foreground and background color to the render Object
|[BaseFrame:init](#BaseFrame:init)|table|Initializes the Frame instance |[BaseFrame:init](#BaseFrame:init)|table|Initializes the Frame instance
|[BaseFrame:mouse_up](#BaseFrame:mouse_up)|-|
|[BaseFrame:multiBlit](#BaseFrame:multiBlit)|-|Renders a multiBlit to the render Object |[BaseFrame:multiBlit](#BaseFrame:multiBlit)|-|Renders a multiBlit to the render Object
|[BaseFrame:render](#BaseFrame:render)|-|Renders the Frame |[BaseFrame:render](#BaseFrame:render)|-|Renders the Frame
|[BaseFrame:setCursor](#BaseFrame:setCursor)|-|Sets the cursor position |[BaseFrame:setCursor](#BaseFrame:setCursor)|-|Sets the cursor position
|[BaseFrame:term_resize](#BaseFrame:term_resize)|-|
|[BaseFrame:textBg](#BaseFrame:textBg)|-|Renders a text with a background color to the render Object |[BaseFrame:textBg](#BaseFrame:textBg)|-|Renders a text with a background color to the render Object
|[BaseFrame:textFg](#BaseFrame:textFg)|-|Renders a text with a foreground color to the render Object |[BaseFrame:textFg](#BaseFrame:textFg)|-|Renders a text with a foreground color to the render Object
@@ -60,8 +58,6 @@ Initializes the Frame instance
### Returns ### Returns
* `table` `self` The initialized instance * `table` `self` The initialized instance
## BaseFrame:mouse_up()
## BaseFrame:multiBlit(x, y, width, height, text, fg, bg) ## BaseFrame:multiBlit(x, y, width, height, text, fg, bg)
Renders a multiBlit to the render Object Renders a multiBlit to the render Object
@@ -85,8 +81,6 @@ Sets the cursor position
* `y` `number` The y position to set the cursor to * `y` `number` The y position to set the cursor to
* `blink` `boolean` Whether the cursor should blink * `blink` `boolean` Whether the cursor should blink
## BaseFrame:term_resize()
## BaseFrame:textBg(x, y, text, bg) ## BaseFrame:textBg(x, y, text, bg)
Renders a text with a background color to the render Object Renders a text with a background color to the render Object

View File

@@ -1,5 +1,5 @@
# Button : VisualElement # Button : VisualElement
This is the button class. It is a visual element that can be clicked. The Button is a standard button element with click handling and state management.
@configDescription Standard button element with click handling and state management @configDescription Standard button element with click handling and state management
## Properties ## Properties

View File

@@ -1,5 +1,5 @@
# Checkbox : VisualElement # Checkbox : VisualElement
This is the checkbox class. It is a visual element that can be checked. The Checkbox is a visual element that can be checked.
## Properties ## Properties

View File

@@ -24,7 +24,7 @@ like Frames, BaseFrames, and more.
|[Container.new](#Container.new)|Container|Creates a new Container instance |[Container.new](#Container.new)|Container|Creates a new Container instance
|[Container:addChild](#Container:addChild)|Container|Adds a child to the container |[Container:addChild](#Container:addChild)|Container|Adds a child to the container
|[Container:blit](#Container:blit)|Container|Draws a line of text and fg and bg as colors |[Container:blit](#Container:blit)|Container|Draws a line of text and fg and bg as colors
|[Container:callChildrenEvents](#Container:callChildrenEvents)|-| |[Container:callChildrenEvents](#Container:callChildrenEvents)|boolean|Calls a event on all children
|[Container:char](#Container:char)|boolean|Handles char events |[Container:char](#Container:char)|boolean|Handles char events
|[Container:clear](#Container:clear)|Container|Clears the container |[Container:clear](#Container:clear)|Container|Clears the container
|[Container:destroy](#Container:destroy)|Container|Destroys the container and its children |[Container:destroy](#Container:destroy)|Container|Destroys the container and its children
@@ -35,10 +35,10 @@ like Frames, BaseFrames, and more.
|[Container:key](#Container:key)|boolean|Handles key events |[Container:key](#Container:key)|boolean|Handles key events
|[Container:key_up](#Container:key_up)|boolean|Handles key up events |[Container:key_up](#Container:key_up)|boolean|Handles key up events
|[Container:mouse_click](#Container:mouse_click)|boolean|Handles mouse click events |[Container:mouse_click](#Container:mouse_click)|boolean|Handles mouse click events
|[Container:mouse_drag](#Container:mouse_drag)|-| |[Container:mouse_drag](#Container:mouse_drag)|boolean|Handles mouse drag events
|[Container:mouse_move](#Container:mouse_move)|-| |[Container:mouse_move](#Container:mouse_move)|boolean|Handles mouse move events
|[Container:mouse_release](#Container:mouse_release)|-| |[Container:mouse_release](#Container:mouse_release)|-|Handles mouse release events
|[Container:mouse_scroll](#Container:mouse_scroll)|-| |[Container:mouse_scroll](#Container:mouse_scroll)|boolean|Handles mouse scroll events
|[Container:mouse_up](#Container:mouse_up)|boolean|Handles mouse up events |[Container:mouse_up](#Container:mouse_up)|boolean|Handles mouse up events
|[Container:multiBlit](#Container:multiBlit)|Container|Draws multiple lines of text, fg and bg strings |[Container:multiBlit](#Container:multiBlit)|Container|Draws multiple lines of text, fg and bg strings
|[Container:registerChildEvent](#Container:registerChildEvent)|Container|Registers the children events of the container |[Container:registerChildEvent](#Container:registerChildEvent)|Container|Registers the children events of the container
@@ -80,7 +80,17 @@ Draws a line of text and fg and bg as colors, it is usually used in the render l
### Returns ### Returns
* `Container` `self` The container instance * `Container` `self` The container instance
## Container:callChildrenEvents() ## Container:callChildrenEvents(visibleOnly, event...)
Calls a event on all children
### Parameters
* `visibleOnly` `boolean` Whether to only call the event on visible children
* `event` `string` The event to call
* `...` *(vararg)* `any` The event arguments
### Returns
* `boolean` `handled` Whether the event was handled
* `table` `child?` The child that handled the event
## Container:char(char) ## Container:char(char)
Handles char events Handles char events
@@ -167,13 +177,46 @@ Handles mouse click events
### Returns ### Returns
* `boolean` `handled` Whether the event was handled * `boolean` `handled` Whether the event was handled
## Container:mouse_drag() ## Container:mouse_drag(button, x, y)
Handles mouse drag events
## Container:mouse_move() ### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
## Container:mouse_release() ### Returns
* `boolean` `handled` Whether the event was handled
## Container:mouse_scroll() ## Container:mouse_move(_, x, y)
Handles mouse move events
### Parameters
* `_` `number` unknown
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `handled` Whether the event was handled
## Container:mouse_release(button, x, y)
Handles mouse release events
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
## Container:mouse_scroll(direction, x, y)
Handles mouse scroll events
### Parameters
* `direction` `number` The direction of the scroll
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `handled` Whether the event was handled
## Container:mouse_up(button, x, y) ## Container:mouse_up(button, x, y)
Handles mouse up events Handles mouse up events

View File

@@ -1,15 +1,26 @@
# Flexbox : Container # Flexbox : Container
This is the Flexbox class. It is a container that arranges its children in a flexible layout.
## Properties
|Property|Type|Default|Description|
|---|---|---|---|
|flexDirection|string|"row"|The direction of the flexbox layout "row" or "column"
|flexSpacing|number|1|The spacing between flex items
|flexJustifyContent|string|"flex-start"|The alignment of flex items along the main axis
|flexWrap|boolean|false|Whether to wrap flex items onto multiple lines
|flexUpdateLayout|boolean|false|Whether to update the layout of the flexbox
## Functions ## Functions
|Method|Returns|Description| |Method|Returns|Description|
|---|---|---| |---|---|---|
|[Flexbox.new](#Flexbox.new)|Flexbox| |[Flexbox.new](#Flexbox.new)|Flexbox|Creates a new Flexbox instance
|[Flexbox:addChild](#Flexbox:addChild)|-| |[Flexbox:addChild](#Flexbox:addChild)|Flexbox|Adds a child element to the flexbox
|[Flexbox:addLineBreak](#Flexbox:addLineBreak)|Flexbox| |[Flexbox:addLineBreak](#Flexbox:addLineBreak)|Flexbox|Adds a new line break to the flexbox.
|[Flexbox:init](#Flexbox:init)|-| |[Flexbox:init](#Flexbox:init)|Flexbox|Initializes the Flexbox instance
|[Flexbox:removeChild](#Flexbox:removeChild)|-| |[Flexbox:removeChild](#Flexbox:removeChild)|Flexbox|Removes a child element from the flexbox
|[Flexbox:render](#Flexbox:render)|-| |[Flexbox:render](#Flexbox:render)|Flexbox|Renders the flexbox and its children
## Flexbox.new() ## Flexbox.new()
Creates a new Flexbox instance Creates a new Flexbox instance
@@ -22,10 +33,17 @@ Creates a new Flexbox instance
local element = Flexbox.new("myId", basalt) local element = Flexbox.new("myId", basalt)
``` ```
## Flexbox:addChild() ## Flexbox:addChild(element)
Adds a child element to the flexbox
### Parameters
* `element` `Element` The child element to add
### Returns
* `Flexbox` `self` The flexbox instance
## Flexbox:addLineBreak(self) ## Flexbox:addLineBreak(self)
Adds a new line break to the flexbox. Adds a new line break to the flexbox
### Parameters ### Parameters
* `self` `Flexbox` The element itself * `self` `Flexbox` The element itself
@@ -33,10 +51,29 @@ Adds a new line break to the flexbox.
### Returns ### Returns
* `nil` `nil` nil * `nil` `nil` nil
## Flexbox:init() ## Flexbox:init(props, basalt)
Initializes the Flexbox instance
## Flexbox:removeChild() ### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Flexbox` `self` The initialized instance
## Flexbox:removeChild(element)
Removes a child element from the flexbox
### Parameters
* `element` `Element` The child element to remove
### Returns
* `Flexbox` `self` The flexbox instance
## Flexbox:render() ## Flexbox:render()
Renders the flexbox and its children
### Returns
* `Flexbox` `self` The flexbox instance

View File

@@ -0,0 +1,89 @@
# Image : VisualElement
This is the Image element class which can be used to display bimg format images.
The bimg format is a universal ComputerCraft image format.
See: https://github.com/SkyTheCodeMaster/bimg
## Properties
|Property|Type|Default|Description|
|---|---|---|---|
|bimg|table|{}|The bimg image data
|currentFrame|number|1|Current animation frame
|metadata|table|{}|Image metadata (version, palette, etc)
## Functions
|Method|Returns|Description|
|---|---|---|
|[Image.new](#Image.new)|-|
|[Image:getPixelData](#Image:getPixelData)|number?|
|[Image:init](#Image:init)|-|
|[Image:loadBimg](#Image:loadBimg)|-|
|[Image:nextFrame](#Image:nextFrame)|-|
|[Image:render](#Image:render)|-|
|[Image:setBg](#Image:setBg)|-|
|[Image:setChar](#Image:setChar)|-|
|[Image:setFg](#Image:setFg)|-|
|[Image:setPixel](#Image:setPixel)|-|
## Image.new()
## Image:getPixelData(x, y)
Gets pixel information at position
### Parameters
* `x` `number` X position
* `y` `number` Y position
### Returns
* `number?` `fg` Foreground color
* `number?` `bg` Background color
* `string?` `char` Character at position
## Image:init()
## Image:loadBimg(bimgData)
Loads a bimg format image
### Parameters
* `bimgData` `table` The bimg image data
## Image:nextFrame()
## Image:render()
## Image:setBg(x, y, color)
Sets background color at position
### Parameters
* `x` `number` X position
* `y` `number` Y position
* `color` `number` Color value (0-15)
## Image:setChar(x, y, char)
Sets character at position
### Parameters
* `x` `number` X position
* `y` `number` Y position
* `char` `string` Single character to set
## Image:setFg(x, y, color)
Sets foreground color at position
### Parameters
* `x` `number` X position
* `y` `number` Y position
* `color` `number` Color value (0-15)
## Image:setPixel(x, y, char, fg, bg)
Sets all properties at position
### Parameters
* `x` `number` X position
* `y` `number` Y position
* `char` `string?` Character to set (optional)
* `fg` `number?` Foreground color (optional)
* `bg` `number?` Background color (optional)

View File

@@ -1,30 +1,24 @@
# Program : VisualElement # Program : VisualElement
This is the program class. It provides a program that runs in a window.
## Properties
|Property|Type|Default|Description|
|---|---|---|---|
|program|table|nil|The program instance
|path|string|""|The path to the program
|running|boolean|false|Whether the program is running
## Functions ## Functions
|Method|Returns|Description| |Method|Returns|Description|
|---|---|---| |---|---|---|
|[BasaltProgram.new](#BasaltProgram.new)|-| |[Program.new](#Program.new)|Program|Creates a new Program instance
|[BasaltProgram:resize](#BasaltProgram:resize)|-| |[Program:dispatchEvent](#Program:dispatchEvent)|any|Handles all incomming events
|[BasaltProgram:resume](#BasaltProgram:resume)|-| |[Program:execute](#Program:execute)|Program|Executes a program
|[BasaltProgram:run](#BasaltProgram:run)|-| |[Program:focus](#Program:focus)|-|Gets called when the element gets focused
|[BasaltProgram:stop](#BasaltProgram:stop)|-| |[Program:init](#Program:init)|Program|Initializes the Program instance
|[Program.new](#Program.new)|Program| |[Program:render](#Program:render)|-|Renders the program
|[Program:dispatchEvent](#Program:dispatchEvent)|-|
|[Program:execute](#Program:execute)|-|
|[Program:focus](#Program:focus)|-|
|[Program:init](#Program:init)|-|
|[Program:render](#Program:render)|-|
## BasaltProgram.new()
## BasaltProgram:resize()
## BasaltProgram:resume()
## BasaltProgram:run()
## BasaltProgram:stop()
## Program.new() ## Program.new()
Creates a new Program instance Creates a new Program instance
@@ -37,14 +31,39 @@ Creates a new Program instance
local element = Program.new("myId", basalt) local element = Program.new("myId", basalt)
``` ```
## Program:dispatchEvent() ## Program:dispatchEvent(event, ...)
Handles all incomming events
## Program:execute() ### Parameters
* `event` `string` The event to handle
* `...` `any` The event arguments
### Returns
* `any` `result` The event result
## Program:execute(path)
Executes a program
### Parameters
* `path` `string` The path to the program
### Returns
* `Program` `self` The Program instance
## Program:focus() ## Program:focus()
Gets called when the element gets focused
## Program:init() ## Program:init(props, basalt)
Initializes the Program instanceProperty
### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
### Returns
* `Program` `self` The initialized instance
## Program:render() ## Program:render()
Renders the program

View File

@@ -26,13 +26,13 @@ A scrollbar element that can be attached to other elements to control their scro
|Method|Returns|Description| |Method|Returns|Description|
|---|---|---| |---|---|---|
|[Scrollbar.new](#Scrollbar.new)|Scrollbar|Creates a new Scrollbar instance |[Scrollbar.new](#Scrollbar.new)|Scrollbar|Creates a new Scrollbar instance
|[Scrollbar:attach](#Scrollbar:attach)|Scrollbar| |[Scrollbar:attach](#Scrollbar:attach)|Scrollbar|Attaches the scrollbar to an element's property
|[Scrollbar:init](#Scrollbar:init)|-| |[Scrollbar:init](#Scrollbar:init)|Scrollbar|Initializes the Scrollbar instance
|[Scrollbar:mouse_click](#Scrollbar:mouse_click)|-| |[Scrollbar:mouse_click](#Scrollbar:mouse_click)|boolean|Handles mouse click events
|[Scrollbar:mouse_drag](#Scrollbar:mouse_drag)|-| |[Scrollbar:mouse_drag](#Scrollbar:mouse_drag)|boolean|Handles mouse drag events
|[Scrollbar:mouse_scroll](#Scrollbar:mouse_scroll)|-| |[Scrollbar:mouse_scroll](#Scrollbar:mouse_scroll)|boolean|Handles mouse scroll events
|[Scrollbar:render](#Scrollbar:render)|-| |[Scrollbar:render](#Scrollbar:render)|-|Renders the scrollbar
|[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|-| |[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|Scrollbar|Updates the attached element's property based on the scrollbar value
## Scrollbar.new() ## Scrollbar.new()
Creates a new Scrollbar instance Creates a new Scrollbar instance
@@ -55,16 +55,56 @@ Attaches the scrollbar to an element's property
### Returns ### Returns
* `Scrollbar` `self` The scrollbar instance * `Scrollbar` `self` The scrollbar instance
## Scrollbar:init() ## Scrollbar:init(props, basalt)
Initializes the Scrollbar instance
## Scrollbar:mouse_click() ### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
## Scrollbar:mouse_drag() ### Returns
* `Scrollbar` `self` The initialized instance
## Scrollbar:mouse_scroll() ## Scrollbar:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The mouse button clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `Whether` the event was handled
## Scrollbar:mouse_drag(button, x, y)
Handles mouse drag events
### Parameters
* `button` `number` The mouse button being dragged
* `x` `number` The x position of the drag
* `y` `number` The y position of the drag
### Returns
* `boolean` `Whether` the event was handled
## Scrollbar:mouse_scroll(direction, x, y)
Handles mouse scroll events
### Parameters
* `direction` `number` The scroll direction (1 for up, -1 for down)
* `x` `number` The x position of the scroll
* `y` `number` The y position of the scroll
### Returns
* `boolean` `Whether` the event was handled
## Scrollbar:render() ## Scrollbar:render()
Renders the Scrollbar
## Scrollbar:updateAttachedElement() ## Scrollbar:updateAttachedElement()
Updates the attached element's property based on the scrollbar value
### Returns
* `Scrollbar` `self` The scrollbar instance

View File

@@ -26,7 +26,7 @@ with customizable colors and value ranges.
|[Slider:getValue](#Slider:getValue)|number|Gets the current value mapped to the max range |[Slider:getValue](#Slider:getValue)|number|Gets the current value mapped to the max range
|[Slider:init](#Slider:init)|Slider|Initializes the Slider instance |[Slider:init](#Slider:init)|Slider|Initializes the Slider instance
|[Slider:mouse_click](#Slider:mouse_click)|boolean|Updates slider position on mouse click |[Slider:mouse_click](#Slider:mouse_click)|boolean|Updates slider position on mouse click
|[Slider:mouse_scroll](#Slider:mouse_scroll)|-| |[Slider:mouse_scroll](#Slider:mouse_scroll)|boolean|Handles mouse release events
|[Slider:render](#Slider:render)|-|Renders the slider with track and handle |[Slider:render](#Slider:render)|-|Renders the slider with track and handle
## Slider.new() ## Slider.new()
@@ -72,7 +72,16 @@ Handles mouse click events
### Returns ### Returns
* `boolean` `handled` Whether the event was handled * `boolean` `handled` Whether the event was handled
## Slider:mouse_scroll() ## Slider:mouse_scroll(button, x, y)
Handles mouse release events
### Parameters
* `button` `number` The mouse button that was released
* `x` `number` The x position of the release
* `y` `number` The y position of the release
### Returns
* `boolean` `handled` Whether the event was handled
## Slider:render() ## Slider:render()
Renders the slider Renders the slider

View File

@@ -25,8 +25,6 @@ row selection, and scrolling capabilities.
|[Table:mouse_click](#Table:mouse_click)|boolean|Handles header clicks for sorting and row selection |[Table:mouse_click](#Table:mouse_click)|boolean|Handles header clicks for sorting and row selection
|[Table:mouse_scroll](#Table:mouse_scroll)|boolean|Handles scrolling through the table data |[Table:mouse_scroll](#Table:mouse_scroll)|boolean|Handles scrolling through the table data
|[Table:render](#Table:render)|-|Renders the table with headers, data and scrollbar |[Table:render](#Table:render)|-|Renders the table with headers, data and scrollbar
|[Table:setColumns](#Table:setColumns)|Table|Sets the table columns configuration
|[Table:setData](#Table:setData)|Table|Sets the table data
|[Table:sortData](#Table:sortData)|Table|Sorts the table data by the specified column |[Table:sortData](#Table:sortData)|Table|Sorts the table data by the specified column
## Table.new() ## Table.new()
@@ -75,34 +73,6 @@ Handles mouse scroll events
## Table:render() ## Table:render()
Renders the table Renders the table
## Table:setColumns(columns)
Sets the table columns
### Parameters
* `columns` `table[]` Array of column definitions {name="Name", width=10}
### Returns
* `Table` `self` The Table instance
### Usage
```lua
table:setColumns({{name="ID", width=4}, {name="Name", width=10}})
```
## Table:setData(data)
Sets the table data
### Parameters
* `data` `table[]` Array of row data arrays
### Returns
* `Table` `self` The Table instance
### Usage
```lua
table:setData({{"1", "Item One"}, {"2", "Item Two"}})
```
## Table:sortData(columnIndex) ## Table:sortData(columnIndex)
Sorts the table data by column Sorts the table data by column

View File

@@ -18,19 +18,23 @@ A multi-line text editor component with cursor support and text manipulation fea
|Method|Returns|Description| |Method|Returns|Description|
|---|---|---| |---|---|---|
|[TextBox.new](#TextBox.new)|-| |[TextBox.new](#TextBox.new)|TextBox|Creates a new TextBox instance
|[TextBox:addSyntaxPattern](#TextBox:addSyntaxPattern)|-| |[TextBox:addSyntaxPattern](#TextBox:addSyntaxPattern)|-|Adds a new syntax highlighting pattern
|[TextBox:char](#TextBox:char)|-| |[TextBox:char](#TextBox:char)|boolean|Handles character input
|[TextBox:getText](#TextBox:getText)|-| |[TextBox:getText](#TextBox:getText)|string|Gets the text of the TextBox
|[TextBox:init](#TextBox:init)|-| |[TextBox:init](#TextBox:init)|TextBox|Initializes the TextBox instance
|[TextBox:key](#TextBox:key)|-| |[TextBox:key](#TextBox:key)|boolean|Handles key events
|[TextBox:mouse_click](#TextBox:mouse_click)|-| |[TextBox:mouse_click](#TextBox:mouse_click)|boolean|Handles mouse click events
|[TextBox:mouse_scroll](#TextBox:mouse_scroll)|-| |[TextBox:mouse_scroll](#TextBox:mouse_scroll)|boolean|Handles mouse scroll events
|[TextBox:render](#TextBox:render)|-| |[TextBox:render](#TextBox:render)|-|Renders the TextBox with syntax highlighting
|[TextBox:setText](#TextBox:setText)|-| |[TextBox:setText](#TextBox:setText)|TextBox|Sets the text of the TextBox
|[TextBox:updateViewport](#TextBox:updateViewport)|-| |[TextBox:updateViewport](#TextBox:updateViewport)|TextBox|Updates the viewport to keep the cursor in view
## TextBox.new() ## TextBox.new()
Creates a new TextBox instance
### Returns
* `TextBox` `self` The newly created TextBox instance
## TextBox:addSyntaxPattern(pattern, color) ## TextBox:addSyntaxPattern(pattern, color)
Adds a new syntax highlighting pattern Adds a new syntax highlighting pattern
@@ -39,22 +43,78 @@ Adds a new syntax highlighting pattern
* `pattern` `string` The regex pattern to match * `pattern` `string` The regex pattern to match
* `color` `colors` The color to apply * `color` `colors` The color to apply
## TextBox:char() ## TextBox:char(char)
Handles character input
### Parameters
* `char` `string` The character that was typed
### Returns
* `boolean` `handled` Whether the event was handled
## TextBox:getText() ## TextBox:getText()
Gets the text of the TextBox
## TextBox:init() ### Returns
* `string` `text` The text of the TextBox
## TextBox:key() ## TextBox:init(props, basalt)
Initializes the TextBox instance
## TextBox:mouse_click() ### Parameters
* `props` `table` The properties to initialize the element with
* `basalt` `table` The basalt instance
## TextBox:mouse_scroll() ### Returns
* `TextBox` `self` The initialized instance
## TextBox:key(key)
Handles key events
### Parameters
* `key` `number` The key that was pressed
### Returns
* `boolean` `handled` Whether the event was handled
## TextBox:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `handled` Whether the event was handled
## TextBox:mouse_scroll(direction, x, y)
Handles mouse scroll events
### Parameters
* `direction` `number` The scroll direction
* `x` `number` The x position of the scroll
* `y` `number` The y position of the scroll
### Returns
* `boolean` `handled` Whether the event was handled
## TextBox:render() ## TextBox:render()
Renders the TextBox
## TextBox:setText() ## TextBox:setText(text)
Sets the text of the TextBox
### Parameters
* `text` `string` The text to set
### Returns
* `TextBox` `self` The TextBox instance
## TextBox:updateViewport() ## TextBox:updateViewport()
Updates the viewport to keep the cursor in view
### Returns
* `TextBox` `self` The TextBox instance

View File

@@ -23,10 +23,10 @@ with support for selection and scrolling.
|[Tree:expandNode](#Tree:expandNode)|Tree|Expands a node to show its children |[Tree:expandNode](#Tree:expandNode)|Tree|Expands a node to show its children
|[Tree:getNodeSize](#Tree:getNodeSize)|number|Gets the size of the tree |[Tree:getNodeSize](#Tree:getNodeSize)|number|Gets the size of the tree
|[Tree:init](#Tree:init)|Tree|Initializes the Tree instance |[Tree:init](#Tree:init)|Tree|Initializes the Tree instance
|[Tree:mouse_click](#Tree:mouse_click)|-| |[Tree:mouse_click](#Tree:mouse_click)|boolean|Handles mouse click events for node selection and expansion
|[Tree:mouse_scroll](#Tree:mouse_scroll)|boolean|Handles mouse scroll events for vertical scrolling
|[Tree:onSelect](#Tree:onSelect)|Tree|Registers a callback for when a node is selected |[Tree:onSelect](#Tree:onSelect)|Tree|Registers a callback for when a node is selected
|[Tree:render](#Tree:render)|-| |[Tree:render](#Tree:render)|-|Renders the tree with nodes, selection and scrolling
|[Tree:setNodes](#Tree:setNodes)|Tree|Sets the tree nodes and expands the root node
|[Tree:toggleNode](#Tree:toggleNode)|Tree|Toggles between expanded and collapsed state |[Tree:toggleNode](#Tree:toggleNode)|Tree|Toggles between expanded and collapsed state
## Tree.new() ## Tree.new()
@@ -75,7 +75,27 @@ Initializes the Tree instance
### Returns ### Returns
* `Tree` `self` The initialized instance * `Tree` `self` The initialized instance
## Tree:mouse_click() ## Tree:mouse_click(button, x, y)
Handles mouse click events
### Parameters
* `button` `number` The button that was clicked
* `x` `number` The x position of the click
* `y` `number` The y position of the click
### Returns
* `boolean` `handled` Whether the event was handled
## Tree:mouse_scroll(direction, x, y)
Handles mouse scroll events
### Parameters
* `direction` `number` The scroll direction (1 for up, -1 for down)
* `x` `number` The x position of the scroll
* `y` `number` The y position of the scroll
### Returns
* `boolean` `handled` Whether the event was handled
## Tree:onSelect(callback) ## Tree:onSelect(callback)
Registers a callback for when a node is selected Registers a callback for when a node is selected
@@ -87,20 +107,7 @@ Registers a callback for when a node is selected
* `Tree` `self` The Tree instance * `Tree` `self` The Tree instance
## Tree:render() ## Tree:render()
Renders the tree
## Tree:setNodes(nodes)
Sets the tree nodes
### Parameters
* `nodes` `table[]` Array of node objects
### Returns
* `Tree` `self` The Tree instance
### Usage
```lua
tree:setNodes({{text="Root", children={{text="Child"}}}})
```
## Tree:toggleNode(node) ## Tree:toggleNode(node)
Toggles a node's expanded state Toggles a node's expanded state

View File

@@ -32,15 +32,18 @@ and provides core functionality for positioning, sizing, colors, and rendering.
|Event|Parameters|Description| |Event|Parameters|Description|
|---|---|---| |---|---|---|
|onMouseClick|`button number, x number, y number`|Fired on mouse click| |onClick|`button, x, y`|Fired on mouse click|
|onMouseUp|`button number, x number, y number`|Fired on mouse button release| |onMouseUp|`button, x, y`|Fired on mouse button release|
|onMouseRelease|`button number, x number, y number`|Fired when mouse leaves while clicked| |onRelease|`button, x, y`|Fired when mouse leaves while clicked|
|onMouseDrag|`button number, x number, y number`|Fired when mouse moves while clicked| |onDrag|`button, x, y`|Fired when mouse moves while clicked|
|onScroll|`direction, x, y`|Fired on mouse scroll|
|onEnter|`-`|Fired when mouse enters element|
|onLeave|`-`|Fired when mouse leaves element|
|onFocus|`-`|Fired when element receives focus| |onFocus|`-`|Fired when element receives focus|
|onBlur|`-`|Fired when element loses focus| |onBlur|`-`|Fired when element loses focus|
|onKey|`key number, code number, isRepeat boolean`|Fired on key press| |onKey|`key`|Fired on key press|
|onKeyUp|`key number, code number`|Fired on key release| |onKeyUp|`key`|Fired on key release|
|onChar|`char string`|Fired on character input| |onChar|`char`|Fired on character input|
## Functions ## Functions