TreeItem

A TreeItem object is the visual representation of an element represented within the dataset of a TreeView. Tree items define attributes such as the element’s label, description, and icon.

The TreeItem class is not subclassable.

let item = new TreeItem("image.png", TreeItemCollapsibleState.None);

item.descriptiveText = "PNG file";
item.path = "path/to/image.png";

Class Methods

constructor(name, [collapsibleState])

Creates a new TreeItem object. The collapsibleState argument defaults to TreeItemCollapsibleState.None.

Properties

name

The display name of the item, as a string.

This property is settable.

collapsibleState

Defines how an item is displayed with regards to being expanded. The default value is TreeItemCollapsibleState.None, which indicates the item cannot be expanded.

Valid values are:

This property is settable.

command

An optional Command to invoke when the item is double-clicked.

This property is settable.

color

When set to a Color object, the color will be rendered as a swatch in the item’s row in place of its image.

If both image and color are set on a tree item, the image will take priority.

This property is settable.

contextValue

A value used when validating the when clause of commands for the tree view. This value may be used for when clauses of the form viewItem == '<contextValue>'.

This property is settable.

descriptiveText

A short description of the item, as a string. This will be displayed alongside the item’s label, if space allows.

This property is settable.

identifier

An optional unique identifier for the item, as a string. This identifier must be unique across the entire tree. This will be used to preserve selection and expansion state.

This property is settable.

image

The name of an image to show for the item (see Images for more information).

If both image and color are set on a tree item, the image will take priority.

This property is settable.

path

The file-system path to the item as a string, if appropriate. If this is specified, and image is not defined, the image will by default use the appropriate file-type image for this path.

This property is settable.

tooltip

A tooltip to display when hovering over the item, as a string.

This property is settable.