TreeView

class TreeView<T> : Region

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.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
open override val children: ObservableList<ScrollPane>

The base class Node has no children, so this is an empty list.

Link copied to clipboard
Link copied to clipboard

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).

Link copied to clipboard
Link copied to clipboard
var root: TreeItem<T>?
Link copied to clipboard
Link copied to clipboard

The value of the currently selected item.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun dumpFlat()

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).

Link copied to clipboard
fun dumpItems()

Prints the tree starting at the root, and descending into all descendant TreeItem.children.

Link copied to clipboard

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.

Link copied to clipboard
open override fun nodePrefHeight(): Float

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.

Link copied to clipboard
open override fun nodePrefWidth(): Float

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.

Link copied to clipboard
fun scrollTo(row: Int)
fun scrollTo(treeItem: TreeItem<T>)