From 5513bf4072d559dced5a14a9aa9d368f5e656e61 Mon Sep 17 00:00:00 2001 From: NoryiE Date: Mon, 24 Feb 2025 19:52:39 +0000 Subject: [PATCH] deploy: 13d3bbd461322d039058041a10e3a60bf0794fbe --- docs/references/elements/BaseElement.md | 2 +- docs/references/elements/BaseFrame.md | 6 -- docs/references/elements/Button.md | 2 +- docs/references/elements/Checkbox.md | 2 +- docs/references/elements/Container.md | 63 ++++++++++++--- docs/references/elements/Flexbox.md | 57 +++++++++++--- docs/references/elements/Image.md | 89 +++++++++++++++++++++ docs/references/elements/Program.md | 67 ++++++++++------ docs/references/elements/Scrollbar.md | 62 ++++++++++++--- docs/references/elements/Slider.md | 13 +++- docs/references/elements/Table.md | 30 -------- docs/references/elements/TextBox.md | 94 +++++++++++++++++++---- docs/references/elements/Tree.md | 43 ++++++----- docs/references/elements/VisualElement.md | 17 ++-- 14 files changed, 409 insertions(+), 138 deletions(-) create mode 100644 docs/references/elements/Image.md diff --git a/docs/references/elements/BaseElement.md b/docs/references/elements/BaseElement.md index 4f7d6bd..3acabb2 100644 --- a/docs/references/elements/BaseElement.md +++ b/docs/references/elements/BaseElement.md @@ -1,5 +1,5 @@ # 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 diff --git a/docs/references/elements/BaseFrame.md b/docs/references/elements/BaseFrame.md index 6fc8e91..4fcbda5 100644 --- a/docs/references/elements/BaseFrame.md +++ b/docs/references/elements/BaseFrame.md @@ -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: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:mouse_up](#BaseFrame:mouse_up)|-| |[BaseFrame:multiBlit](#BaseFrame:multiBlit)|-|Renders a multiBlit to the render Object |[BaseFrame:render](#BaseFrame:render)|-|Renders the Frame |[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:textFg](#BaseFrame:textFg)|-|Renders a text with a foreground color to the render Object @@ -60,8 +58,6 @@ Initializes the Frame instance ### Returns * `table` `self` The initialized instance -## BaseFrame:mouse_up() - ## BaseFrame:multiBlit(x, y, width, height, text, fg, bg) 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 * `blink` `boolean` Whether the cursor should blink -## BaseFrame:term_resize() - ## BaseFrame:textBg(x, y, text, bg) Renders a text with a background color to the render Object diff --git a/docs/references/elements/Button.md b/docs/references/elements/Button.md index 8e10c43..b2bf6b6 100644 --- a/docs/references/elements/Button.md +++ b/docs/references/elements/Button.md @@ -1,5 +1,5 @@ # 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 ## Properties diff --git a/docs/references/elements/Checkbox.md b/docs/references/elements/Checkbox.md index defd83c..f3f92c4 100644 --- a/docs/references/elements/Checkbox.md +++ b/docs/references/elements/Checkbox.md @@ -1,5 +1,5 @@ # 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 diff --git a/docs/references/elements/Container.md b/docs/references/elements/Container.md index dfca931..76eb293 100644 --- a/docs/references/elements/Container.md +++ b/docs/references/elements/Container.md @@ -24,7 +24,7 @@ like Frames, BaseFrames, and more. |[Container.new](#Container.new)|Container|Creates a new Container instance |[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:callChildrenEvents](#Container:callChildrenEvents)|-| +|[Container:callChildrenEvents](#Container:callChildrenEvents)|boolean|Calls a event on all children |[Container:char](#Container:char)|boolean|Handles char events |[Container:clear](#Container:clear)|Container|Clears the container |[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_up](#Container:key_up)|boolean|Handles key up events |[Container:mouse_click](#Container:mouse_click)|boolean|Handles mouse click events -|[Container:mouse_drag](#Container:mouse_drag)|-| -|[Container:mouse_move](#Container:mouse_move)|-| -|[Container:mouse_release](#Container:mouse_release)|-| -|[Container:mouse_scroll](#Container:mouse_scroll)|-| +|[Container:mouse_drag](#Container:mouse_drag)|boolean|Handles mouse drag events +|[Container:mouse_move](#Container:mouse_move)|boolean|Handles mouse move events +|[Container:mouse_release](#Container:mouse_release)|-|Handles mouse release events +|[Container:mouse_scroll](#Container:mouse_scroll)|boolean|Handles mouse scroll 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: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 * `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) Handles char events @@ -167,13 +177,46 @@ Handles mouse click events ### Returns * `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) Handles mouse up events diff --git a/docs/references/elements/Flexbox.md b/docs/references/elements/Flexbox.md index 0e7be8a..774e004 100644 --- a/docs/references/elements/Flexbox.md +++ b/docs/references/elements/Flexbox.md @@ -1,15 +1,26 @@ # 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 |Method|Returns|Description| |---|---|---| -|[Flexbox.new](#Flexbox.new)|Flexbox| -|[Flexbox:addChild](#Flexbox:addChild)|-| -|[Flexbox:addLineBreak](#Flexbox:addLineBreak)|Flexbox| -|[Flexbox:init](#Flexbox:init)|-| -|[Flexbox:removeChild](#Flexbox:removeChild)|-| -|[Flexbox:render](#Flexbox:render)|-| +|[Flexbox.new](#Flexbox.new)|Flexbox|Creates a new Flexbox instance +|[Flexbox:addChild](#Flexbox:addChild)|Flexbox|Adds a child element to the flexbox +|[Flexbox:addLineBreak](#Flexbox:addLineBreak)|Flexbox|Adds a new line break to the flexbox. +|[Flexbox:init](#Flexbox:init)|Flexbox|Initializes the Flexbox instance +|[Flexbox:removeChild](#Flexbox:removeChild)|Flexbox|Removes a child element from the flexbox +|[Flexbox:render](#Flexbox:render)|Flexbox|Renders the flexbox and its children ## Flexbox.new() Creates a new Flexbox instance @@ -22,10 +33,17 @@ Creates a new Flexbox instance 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) -Adds a new line break to the flexbox. +Adds a new line break to the flexbox ### Parameters * `self` `Flexbox` The element itself @@ -33,10 +51,29 @@ Adds a new line break to the flexbox. ### Returns * `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() +Renders the flexbox and its children + +### Returns +* `Flexbox` `self` The flexbox instance diff --git a/docs/references/elements/Image.md b/docs/references/elements/Image.md new file mode 100644 index 0000000..9b91d8b --- /dev/null +++ b/docs/references/elements/Image.md @@ -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) + + diff --git a/docs/references/elements/Program.md b/docs/references/elements/Program.md index ab6fae7..b43bc74 100644 --- a/docs/references/elements/Program.md +++ b/docs/references/elements/Program.md @@ -1,30 +1,24 @@ # 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 |Method|Returns|Description| |---|---|---| -|[BasaltProgram.new](#BasaltProgram.new)|-| -|[BasaltProgram:resize](#BasaltProgram:resize)|-| -|[BasaltProgram:resume](#BasaltProgram:resume)|-| -|[BasaltProgram:run](#BasaltProgram:run)|-| -|[BasaltProgram:stop](#BasaltProgram:stop)|-| -|[Program.new](#Program.new)|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)|Program|Creates a new Program instance +|[Program:dispatchEvent](#Program:dispatchEvent)|any|Handles all incomming events +|[Program:execute](#Program:execute)|Program|Executes a program +|[Program:focus](#Program:focus)|-|Gets called when the element gets focused +|[Program:init](#Program:init)|Program|Initializes the Program instance +|[Program:render](#Program:render)|-|Renders the program ## Program.new() Creates a new Program instance @@ -37,14 +31,39 @@ Creates a new Program instance 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() +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() +Renders the program diff --git a/docs/references/elements/Scrollbar.md b/docs/references/elements/Scrollbar.md index 49eb965..cec5f6f 100644 --- a/docs/references/elements/Scrollbar.md +++ b/docs/references/elements/Scrollbar.md @@ -26,13 +26,13 @@ A scrollbar element that can be attached to other elements to control their scro |Method|Returns|Description| |---|---|---| |[Scrollbar.new](#Scrollbar.new)|Scrollbar|Creates a new Scrollbar instance -|[Scrollbar:attach](#Scrollbar:attach)|Scrollbar| -|[Scrollbar:init](#Scrollbar:init)|-| -|[Scrollbar:mouse_click](#Scrollbar:mouse_click)|-| -|[Scrollbar:mouse_drag](#Scrollbar:mouse_drag)|-| -|[Scrollbar:mouse_scroll](#Scrollbar:mouse_scroll)|-| -|[Scrollbar:render](#Scrollbar:render)|-| -|[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|-| +|[Scrollbar:attach](#Scrollbar:attach)|Scrollbar|Attaches the scrollbar to an element's property +|[Scrollbar:init](#Scrollbar:init)|Scrollbar|Initializes the Scrollbar instance +|[Scrollbar:mouse_click](#Scrollbar:mouse_click)|boolean|Handles mouse click events +|[Scrollbar:mouse_drag](#Scrollbar:mouse_drag)|boolean|Handles mouse drag events +|[Scrollbar:mouse_scroll](#Scrollbar:mouse_scroll)|boolean|Handles mouse scroll events +|[Scrollbar:render](#Scrollbar:render)|-|Renders the scrollbar +|[Scrollbar:updateAttachedElement](#Scrollbar:updateAttachedElement)|Scrollbar|Updates the attached element's property based on the scrollbar value ## Scrollbar.new() Creates a new Scrollbar instance @@ -55,16 +55,56 @@ Attaches the scrollbar to an element's property ### Returns * `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() +Renders the Scrollbar ## Scrollbar:updateAttachedElement() +Updates the attached element's property based on the scrollbar value + +### Returns +* `Scrollbar` `self` The scrollbar instance diff --git a/docs/references/elements/Slider.md b/docs/references/elements/Slider.md index c1560fd..05fb1cb 100644 --- a/docs/references/elements/Slider.md +++ b/docs/references/elements/Slider.md @@ -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:init](#Slider:init)|Slider|Initializes the Slider instance |[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.new() @@ -72,7 +72,16 @@ Handles mouse click events ### Returns * `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() Renders the slider diff --git a/docs/references/elements/Table.md b/docs/references/elements/Table.md index 5284222..2bd0672 100644 --- a/docs/references/elements/Table.md +++ b/docs/references/elements/Table.md @@ -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_scroll](#Table:mouse_scroll)|boolean|Handles scrolling through the table data |[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.new() @@ -75,34 +73,6 @@ Handles mouse scroll events ## Table:render() 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) Sorts the table data by column diff --git a/docs/references/elements/TextBox.md b/docs/references/elements/TextBox.md index 9dbbadf..9ed4280 100644 --- a/docs/references/elements/TextBox.md +++ b/docs/references/elements/TextBox.md @@ -18,19 +18,23 @@ A multi-line text editor component with cursor support and text manipulation fea |Method|Returns|Description| |---|---|---| -|[TextBox.new](#TextBox.new)|-| -|[TextBox:addSyntaxPattern](#TextBox:addSyntaxPattern)|-| -|[TextBox:char](#TextBox:char)|-| -|[TextBox:getText](#TextBox:getText)|-| -|[TextBox:init](#TextBox:init)|-| -|[TextBox:key](#TextBox:key)|-| -|[TextBox:mouse_click](#TextBox:mouse_click)|-| -|[TextBox:mouse_scroll](#TextBox:mouse_scroll)|-| -|[TextBox:render](#TextBox:render)|-| -|[TextBox:setText](#TextBox:setText)|-| -|[TextBox:updateViewport](#TextBox:updateViewport)|-| +|[TextBox.new](#TextBox.new)|TextBox|Creates a new TextBox instance +|[TextBox:addSyntaxPattern](#TextBox:addSyntaxPattern)|-|Adds a new syntax highlighting pattern +|[TextBox:char](#TextBox:char)|boolean|Handles character input +|[TextBox:getText](#TextBox:getText)|string|Gets the text of the TextBox +|[TextBox:init](#TextBox:init)|TextBox|Initializes the TextBox instance +|[TextBox:key](#TextBox:key)|boolean|Handles key events +|[TextBox:mouse_click](#TextBox:mouse_click)|boolean|Handles mouse click events +|[TextBox:mouse_scroll](#TextBox:mouse_scroll)|boolean|Handles mouse scroll events +|[TextBox:render](#TextBox:render)|-|Renders the TextBox with syntax highlighting +|[TextBox:setText](#TextBox:setText)|TextBox|Sets the text of the TextBox +|[TextBox:updateViewport](#TextBox:updateViewport)|TextBox|Updates the viewport to keep the cursor in view ## TextBox.new() +Creates a new TextBox instance + +### Returns +* `TextBox` `self` The newly created TextBox instance ## TextBox:addSyntaxPattern(pattern, color) Adds a new syntax highlighting pattern @@ -39,22 +43,78 @@ Adds a new syntax highlighting pattern * `pattern` `string` The regex pattern to match * `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() +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() +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() +Updates the viewport to keep the cursor in view + +### Returns +* `TextBox` `self` The TextBox instance diff --git a/docs/references/elements/Tree.md b/docs/references/elements/Tree.md index e06c6a8..b40d113 100644 --- a/docs/references/elements/Tree.md +++ b/docs/references/elements/Tree.md @@ -23,10 +23,10 @@ with support for selection and scrolling. |[Tree:expandNode](#Tree:expandNode)|Tree|Expands a node to show its children |[Tree:getNodeSize](#Tree:getNodeSize)|number|Gets the size of the tree |[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:render](#Tree:render)|-| -|[Tree:setNodes](#Tree:setNodes)|Tree|Sets the tree nodes and expands the root node +|[Tree:render](#Tree:render)|-|Renders the tree with nodes, selection and scrolling |[Tree:toggleNode](#Tree:toggleNode)|Tree|Toggles between expanded and collapsed state ## Tree.new() @@ -75,7 +75,27 @@ Initializes the Tree instance ### Returns * `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) 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:render() - -## 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"}}}}) -``` +Renders the tree ## Tree:toggleNode(node) Toggles a node's expanded state diff --git a/docs/references/elements/VisualElement.md b/docs/references/elements/VisualElement.md index 277f7b0..6ddc500 100644 --- a/docs/references/elements/VisualElement.md +++ b/docs/references/elements/VisualElement.md @@ -32,15 +32,18 @@ and provides core functionality for positioning, sizing, colors, and rendering. |Event|Parameters|Description| |---|---|---| -|onMouseClick|`button number, x number, y number`|Fired on mouse click| -|onMouseUp|`button number, x number, y number`|Fired on mouse button release| -|onMouseRelease|`button number, x number, y number`|Fired when mouse leaves while clicked| -|onMouseDrag|`button number, x number, y number`|Fired when mouse moves while clicked| +|onClick|`button, x, y`|Fired on mouse click| +|onMouseUp|`button, x, y`|Fired on mouse button release| +|onRelease|`button, x, y`|Fired when mouse leaves 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| |onBlur|`-`|Fired when element loses focus| -|onKey|`key number, code number, isRepeat boolean`|Fired on key press| -|onKeyUp|`key number, code number`|Fired on key release| -|onChar|`char string`|Fired on character input| +|onKey|`key`|Fired on key press| +|onKeyUp|`key`|Fired on key release| +|onChar|`char`|Fired on character input| ## Functions