diff --git a/docs/references/elements/BaseElement.md b/docs/references/elements/BaseElement.md index c09f096..4f7d6bd 100644 --- a/docs/references/elements/BaseElement.md +++ b/docs/references/elements/BaseElement.md @@ -8,14 +8,15 @@ The base class for all UI elements in Basalt |type|string|BaseElement|The type identifier of the element |id|string|BaseElement|The unique identifier for the element |name|string|BaseElement|The name of the element -|eventCallbacks|table|{}|Table containing all registered event callbacks +|eventCallbacks|table|BaseElement|The event callbacks for the element ## Functions |Method|Returns|Description| |---|---|---| -|[BaseElement.listenTo](#BaseElement.listenTo)|-|Registers an event that this class can listen to +|[BaseElement.defineEvent](#BaseElement.defineEvent)|-| |[BaseElement.new](#BaseElement.new)|table|Creates a new BaseElement instance +|[BaseElement.registerEventCallback](#BaseElement.registerEventCallback)|-| |[BaseElement:destroy](#BaseElement:destroy)|-|Destroys the element and cleans up all references |[BaseElement:dispatchEvent](#BaseElement:dispatchEvent)|boolean?|Handles all events |[BaseElement:fireEvent](#BaseElement:fireEvent)|table|Triggers an event and calls all registered callbacks @@ -28,18 +29,7 @@ The base class for all UI elements in Basalt |[BaseElement:registerCallback](#BaseElement:registerCallback)|table|Registers a callback function |[BaseElement:updateRender](#BaseElement:updateRender)|-|Requests a render update for this element -## BaseElement.listenTo(class, eventName, event?) -Registers an event that this class can listen to - -### Parameters -* `class` `table` The class to add the event to -* `eventName` `string` The name of the event to register -* `event` *(optional)* `string` The event to handle - -### Usage - ```lua -BaseElement.listenTo(MyClass, "mouse_click") -``` +## BaseElement.defineEvent() ## BaseElement.new(props, basalt) Creates a new BaseElement instance @@ -56,6 +46,8 @@ Creates a new BaseElement instance local element = BaseElement.new() ``` +## BaseElement.registerEventCallback() + ## BaseElement:destroy() Destroys the element and cleans up all references diff --git a/docs/references/elements/Button.md b/docs/references/elements/Button.md index 9b4b634..8e10c43 100644 --- a/docs/references/elements/Button.md +++ b/docs/references/elements/Button.md @@ -1,4 +1,6 @@ # Button : VisualElement +This is the button class. It is a visual element that can be clicked. +@configDescription Standard button element with click handling and state management ## Properties @@ -15,14 +17,24 @@ |Method|Returns|Description| |---|---|---| -|[Button.new](#Button.new)|-| -|[Button:init](#Button:init)|-| -|[Button:render](#Button:render)|-| +|[Button.new](#Button.new)|table|Creates a new Button instance +|[Button:init](#Button:init)|-|Initializes the Button instance +|[Button:render](#Button:render)|-|Renders the Button ## Button.new() +Creates a new Button instance -## Button:init() +### Returns +* `table` `self` The created instance + +## Button:init(props, basalt) +Initializes the Button instance + +### Parameters +* `props` `table` The properties to initialize the element with +* `basalt` `table` The basalt instance ## Button:render() +Renders the Button diff --git a/docs/references/elements/Container.md b/docs/references/elements/Container.md index efa3349..dfca931 100644 --- a/docs/references/elements/Container.md +++ b/docs/references/elements/Container.md @@ -48,6 +48,7 @@ like Frames, BaseFrames, and more. |[Container:render](#Container:render)|-|Renders the container |[Container:sortChildren](#Container:sortChildren)|Container|Sorts the children of the container |[Container:sortChildrenEvents](#Container:sortChildrenEvents)|Container|Sorts the children events of the container +|[Container:textBg](#Container:textBg)|Container|Draws a line of text and bg as color |[Container:textFg](#Container:textFg)|Container|Draws a line of text and fg as color |[Container:unregisterChildEvent](#Container:unregisterChildEvent)|Container|Unregisters the children events of the container @@ -255,6 +256,18 @@ Sorts the children events of the container ### Returns * `Container` `self` The container instance +## Container:textBg(x, y, text, bg) +Draws a line of text and bg as color, it is usually used in the render loop + +### Parameters +* `x` `number` The x position to draw the text +* `y` `number` The y position to draw the text +* `text` `string` The text to draw +* `bg` `color` The background color of the text + +### Returns +* `Container` `self` The container instance + ## Container:textFg(x, y, text, fg) Draws a line of text and fg as color, it is usually used in the render loop diff --git a/docs/references/elements/Frame.md b/docs/references/elements/Frame.md index 6b3387f..118e4d5 100644 --- a/docs/references/elements/Frame.md +++ b/docs/references/elements/Frame.md @@ -1,12 +1,6 @@ # Frame : Container This is the frame class. It serves as a grouping container for other elements. -## Events - -|Event|Parameters|Description| -|---|---|---| -|onResize|`width number, height number`|Fired when the frame is resized| - ## Functions |Method|Returns|Description| diff --git a/docs/references/elements/List.md b/docs/references/elements/List.md index dd26506..6b05a06 100644 --- a/docs/references/elements/List.md +++ b/docs/references/elements/List.md @@ -6,11 +6,12 @@ custom item rendering, separators, and selection handling. |Property|Type|Default|Description| |---|---|---|---| -|items|table|{}|List of items to display. Items can be strings or tables with properties -|selectedIndex|number|0|Index of the currently selected item (0 means no selection) +|items|table|{}|List of items to display. Items can be tables with properties including selected state |selectable|boolean|true|Whether items in the list can be selected +|multiSelection|boolean|false|Whether multiple items can be selected at once |offset|number|0|Current scroll offset for viewing long lists -|selectedColor|color|blue|Background color for the selected item +|selectedBackground|color|blue|Background color for selected items +|selectedForeground|color|white|Text color for selected items ## Events @@ -25,6 +26,7 @@ custom item rendering, separators, and selection handling. |[List.new](#List.new)|List|Creates a new List instance |[List:addItem](#List:addItem)|List|Adds an item to the list |[List:clear](#List:clear)|List|Clears all items from the list +|[List:getSelectedItems](#List:getSelectedItems)|table|Gets the currently selected items |[List:init](#List:init)|List|Initializes the List instance |[List:mouse_click](#List:mouse_click)|boolean|Handles mouse click events |[List:mouse_scroll](#List:mouse_scroll)|boolean|Handles mouse scroll events @@ -69,6 +71,17 @@ Clears all items from the list list:clear() ``` +## List:getSelectedItems() +Gets the currently selected items + +### Returns +* `table` `selected` List of selected items + +### Usage + ```lua +local selected = list:getSelectedItems() +``` + ## List:init(props, basalt) Initializes the List instance diff --git a/docs/references/elements/Menu.md b/docs/references/elements/Menu.md index 8f2249d..e2ebe49 100644 --- a/docs/references/elements/Menu.md +++ b/docs/references/elements/Menu.md @@ -1,5 +1,5 @@ # Menu : List -This is the menu class. It provides a horizontal menu bar with selectable items and separators. +This is the menu class. It provides a horizontal menu bar with selectable items. Menu items are displayed in a single row and can have custom colors and callbacks. ## Properties diff --git a/docs/references/elements/VisualElement.md b/docs/references/elements/VisualElement.md index 4b1cafe..277f7b0 100644 --- a/docs/references/elements/VisualElement.md +++ b/docs/references/elements/VisualElement.md @@ -61,6 +61,7 @@ and provides core functionality for positioning, sizing, colors, and rendering. |[VisualElement:mouse_release](#VisualElement:mouse_release)|-|Handles a mouse release event |[VisualElement:mouse_scroll](#VisualElement:mouse_scroll)|-| |[VisualElement:mouse_up](#VisualElement:mouse_up)|boolean|Handles a mouse up event +|[VisualElement:multiBlit](#VisualElement:multiBlit)|-|Multi-character drawing with colors |[VisualElement:render](#VisualElement:render)|-|Renders the element |[VisualElement:setCursor](#VisualElement:setCursor)|-|Sets the cursor position |[VisualElement:textBg](#VisualElement:textBg)|-|Draws text with background color @@ -169,6 +170,18 @@ Handles a mouse up event ### Returns * `boolean` `release` Whether the element was released on the element +## VisualElement:multiBlit(x, y, width, height, text, fg, bg) +Draws multiple characters at once with colors + +### Parameters +* `x` `number` The x position to draw +* `y` `number` The y position to draw +* `width` `number` The width of the area to draw +* `height` `number` The height of the area to draw +* `text` `string` The text to draw +* `fg` `string` The foreground color +* `bg` `string` The background color + ## VisualElement:render() Renders the element