An internal control for a single item inside Tree.
A single item of a Tree control. It can contain other TreeItems as children, which allows it to create a hierarchy. It can also contain text and buttons. TreeItem is not a Node, it is internal to the Tree.
To create a TreeItem, use Tree.create_item() or create_child(). To remove a TreeItem, use Object.free().
Note: The ID values used for buttons are 32-bit, unlike int which is always 64-bit. They go from -2147483648 to 2147483647.
Adds a button with Texture2D button to the end of the cell at column column. The id is used to identify the button in the according Tree.button_clicked signal and can be different from the buttons index. If not specified, the next available index is used, which may be retrieved by calling get_button_count() immediately before this method. Optionally, the button can be disabled and have a tooltip_text. description is used as the button description for assistive apps.
Adds a previously unparented TreeItem as a direct child of this one. The child item must not be a part of any Tree or parented to any TreeItem. See also remove_child().
Calls the method on the actual TreeItem and its children recursively. Pass parameters as a comma separated list.
Creates an item and adds it as a child.
The new item will be inserted as position index (the default value -1 means the last position), or it will be the last child if index is higher than the child count.
Returns the text autowrap mode in the given column. By default it is TextServer.AUTOWRAP_OFF.
Returns the autowrap trim flags for the given column. By default, both TextServer.BREAK_TRIM_START_EDGE_SPACES and TextServer.BREAK_TRIM_END_EDGE_SPACES are enabled.
Returns the Texture2D of the button at index button_index in column column.
Returns the color of the button with ID id in column column. If the specified button does not exist, returns Color.BLACK.
Returns a child item by its index (see get_child_count()). This method is often used for iterating all children of an item.
Negative indices access the children from the last one.
Returns the given column's custom StyleBox used to draw the background.
Returns the given column's icon Texture2D. Error if no icon is set.
Returns the node's order in the tree. For example, if called on the first child item the position is 0.
Returns the metadata value that was set for the given column using set_metadata().
Returns the next TreeItem in the tree (in the context of a depth-first search) or a null object if there is none.
If wrap is enabled, the method will wrap around to the first element in the tree when called on the last element, otherwise it returns null.
Returns the next visible TreeItem in the tree (in the context of a depth-first search) or a null object if there is none.
If wrap is enabled, the method will wrap around to the first visible element in the tree when called on the last visible element, otherwise it returns null.
Returns the previous TreeItem in the tree (in the context of a depth-first search) or a null object if there is none.
If wrap is enabled, the method will wrap around to the last element in the tree when called on the first visible element, otherwise it returns null.
Returns the previous visible sibling TreeItem in the tree (in the context of a depth-first search) or a null object if there is none.
If wrap is enabled, the method will wrap around to the last visible element in the tree when called on the first visible element, otherwise it returns null.
Returns a dictionary containing the range parameters for a given column. The keys are "min", "max", "step", and "expr".
Returns the clipping behavior when the text exceeds the item's bounding rectangle in the given column. By default it is TextServer.OVERRUN_TRIM_ELLIPSIS.
Returns true if the cell was made into a button with set_custom_as_button().
Returns true if visible is true and all its ancestors are also visible.
Propagates this item's checked status to its children and parents for the given column. It is possible to process the items affected by this method call by connecting to Tree.check_propagated_to_item. The order that the items affected will be processed is as follows: the item invoking this method, children of that item, and finally parents of that item. If emit_signal is false, then Tree.check_propagated_to_item will not be emitted.
Removes the given child TreeItem and all its children from the Tree. Note that it doesn't free the item from memory, so it can be reused later (see add_child()). To completely remove a TreeItem use Object.free().
Note: If you want to move a child from one Tree to another, then instead of removing and adding it manually you can use move_before() or move_after().
Selects the given column. If set_as_cursor is true, the Tree's cursor will be moved to this item (only matters if Tree.select_mode is set to Tree.SELECT_MULTI).
Sets the given column's auto translate mode to mode.
All columns use Node.AUTO_TRANSLATE_MODE_INHERIT by default, which uses the same auto translate mode as the Tree itself.
Sets the autowrap mode in the given column. If set to something other than TextServer.AUTOWRAP_OFF, the text gets wrapped inside the cell's bounding rectangle.
Sets the autowrap trim flags for the given column. These flags control whether leading and trailing spaces are trimmed on wrapped lines. Set to 0 to disable all trimming.
Sets the given column's button Texture2D at index button_index to button.
Collapses or uncollapses this TreeItem and all the descendants of this item.
Makes a cell with CELL_MODE_CUSTOM display as a non-flat button with a StyleBox.
Sets the given column's custom background color and whether to just use it as an outline.
Note: If a custom StyleBox is set, the background color will be drawn behind it.
Sets the given column's custom draw callback. Use an empty Callable ([code skip-lint]Callable()[/code]) to clear the custom callback. The cell has to be in CELL_MODE_CUSTOM to use this feature.
The callback should accept two arguments: the TreeItem that is drawn and its position and size as a Rect2.
To draw custom content over the native style, please use Tree.get_custom_drawing_canvas_item().
If multiline is true, the given column is multiline editable.
Note: This option only affects the type of control (LineEdit or TextEdit) that appears when editing the column. You can set multiline values with set_text() even if the column is not multiline editable.
Sets the given cell's icon Texture2D. If the cell is in CELL_MODE_ICON mode, the icon is displayed in the center of the cell. Otherwise, the icon is displayed before the cell's text. CELL_MODE_RANGE does not display an icon.
Sets the maximum allowed width of the icon in the given column. This limit is applied on top of the default size of the icon and on top of Tree.icon_max_width. The height is adjusted according to the icon's ratio.
Sets the given cell's icon overlay Texture2D. The cell has to be in CELL_MODE_ICON mode, and icon has to be set. Overlay is drawn on top of icon, in the bottom left corner.
If indeterminate is true, the given column is marked indeterminate.
Note: If set true from false, then column is cleared of checked status.
Sets the language code of the given column's text to language. This is used for line-breaking and text shaping algorithms. If language is empty, the current locale is used.
Sets the metadata value for the given column, which can be retrieved later using get_metadata(). This can be used, for example, to store a reference to the original data.
Sets the range of accepted values for a column. The column must be in the CELL_MODE_RANGE mode.
If expr is true, the edit mode slider will use an exponential scale as with Range.exp_edit.
Set BiDi algorithm override for the structured text. Has effect for cells that display text.
CELL_MODE_STRING = 0Cell shows a string label, optionally with an icon. When editable, the text can be edited using a LineEdit, or a TextEdit popup if set_edit_multiline() is used.
CELL_MODE_CHECK = 1Cell shows a checkbox, optionally with text and an icon. The checkbox can be pressed, released, or indeterminate (via set_indeterminate()). The checkbox can't be clicked unless the cell is editable.
CELL_MODE_RANGE = 2Cell shows a numeric range. When editable, it can be edited using a range slider. Use set_range() to set the value and set_range_config() to configure the range.
This cell can also be used in a text dropdown mode when you assign a text with set_text(). Separate options with a comma, e.g. "Option1,Option2,Option3".
CELL_MODE_ICON = 3Cell shows an icon. It can't be edited nor display text. The icon is always centered within the cell.
CELL_MODE_CUSTOM = 4Cell shows as a clickable button. It will display an arrow similar to OptionButton, but doesn't feature a dropdown (for that you can use CELL_MODE_RANGE). Clicking the button emits the Tree.item_edited signal. The button is flat by default, you can use set_custom_as_button() to display it with a StyleBox.
This mode also supports custom drawing using set_custom_draw_callback().