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

@@ -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