import{_ as t,a,b as r,ag as d}from"./chunks/framework.BcrMLAmg.js";const p=JSON.parse('{"title":"Tree","description":"","frontmatter":{},"headers":[],"relativePath":"references/elements/Tree.md","filePath":"references/elements/Tree.md","lastUpdated":1757844696000}'),o={name:"references/elements/Tree.md"};function l(n,e,s,i,c,h){return r(),a("div",null,e[0]||(e[0]=[d('
This is the tree class. It provides a hierarchical view of nodes that can be expanded and collapsed,with support for selection and scrolling.
Extends: VisualElement
| Property | Type | Default | Description |
|---|---|---|---|
| nodes | table | {} | The tree structure containing node objects with {text, children} properties |
| expandedNodes | table | {} | Table of nodes that are currently expanded |
| scrollOffset | number | 0 | Current vertical scroll position |
| horizontalOffset | number | 0 | Current horizontal scroll position |
| nodeColor | color | white | Color of unselected nodes |
| selectedColor | color | lightBlue | Background color of selected node |
| Method | Returns | Description |
|---|---|---|
| Tree:expandNode | Tree | Expands a node to show its children |
| Tree:collapseNode | Tree | Collapses a node to hide its children |
| Tree:toggleNode | Tree | Toggles between expanded and collapsed state |
| Tree:onSelect | Tree | Registers a callback for when a node is selected |
| Tree:getNodeSize | number, number | Gets the size of the tree |
Expands a node
node table The node to expandTree self The Tree instanceCollapses a node
node table The node to collapseTree self The Tree instanceToggles a node's expanded state
node table The node to toggleTree self The Tree instanceRegisters a callback for when a node is selected
callback function The callback functionTree self The Tree instanceGets the size of the tree
number width The width of the treenumber height The height of the tree