TreeView
Displays a hierarchical list of TreeItems in a tree structure. Each TreeItem can be a leaf
, meaning it has no children. If it is not a leaf, then its children can be shown/hidden by either clicking on the "expand/contract" button (an arrow using Glok's default theme), or by double-clicking anywhere on the item.
This is most suitable when each TreeItem holds similar data, such as the hierarchical view of a file system, where each TreeItem is related to a File
(which may also be a folder).
For trees with mixed types (e.g. the composition of a document, which may contain text, images, layers, guides, meta-data ...), consider using MixedTreeView instead.
T is the type of data held by a single TreeItem. e.g. File
in the example above.
Properties
The base class Node has no children, so this is an empty list.
At a later date, TreeView may support variable size cells, and a negative number would indicate that each cell has its own custom height. But for now, this should always be set to greater than zero (either directly in code, or via the scene's Theme).
The value of the currently selected item.
Functions
Prints the root node, and then all descendant TreeItem.children for TreeItems which are expanded. i.e. The TreeItems that are visible if you scroll from the top of the TreeView to the bottom, plus the root node (even when showRoot == true).
Prints the tree starting at the root, and descending into all descendant TreeItem.children.
Expands all ancestor TreeItems, and repositions the vertical scroll bar, if needed, so that item is available, and then scroll the tree to make it visible.
By default, TreeViews have an arbitrary prefHeight. Set evalPrefHeight, or add the TreeView to a layout control which will allocate a sensible area regardless of evalPrefWidth.
By default, TreeViews have an arbitrary prefWidth. Set evalPrefWidth, or add the TreeView to a layout control which will allocate a sensible area regardless of evalPrefWidth.