TreeItem

Inherits: Object

Control for a single item inside a Tree.

Description

Control for a single item inside a Tree. May have child TreeItems and be styled as well as contain buttons.

You can remove a TreeItem by using Object.free.

Properties

boolcollapsed
intcustom_minimum_height
booldisable_folding

Methods

voidadd_button ( int column, Texture button, int button_idx=-1, bool disabled=false, String tooltip=”” )
Variantcall_recursive ( String method, … ) vararg
voidclear_custom_bg_color ( int column )
voidclear_custom_color ( int column )
voiddeselect ( int column )
voiderase_button ( int column, int button_idx )
Textureget_button ( int column, int button_idx ) const
intget_button_count ( int column ) const
Stringget_button_tooltip ( int column, int button_idx ) const
TreeCellModeget_cell_mode ( int column ) const
TreeItemget_children ( )
Colorget_custom_bg_color ( int column ) const
Colorget_custom_color ( int column ) const
boolget_expand_right ( int column ) const
Textureget_icon ( int column ) const
intget_icon_max_width ( int column ) const
Colorget_icon_modulate ( int column ) const
Rect2get_icon_region ( int column ) const
Variantget_metadata ( int column ) const
TreeItemget_next ( )
TreeItemget_next_visible ( bool wrap=false )
TreeItemget_parent ( )
TreeItemget_prev ( )
TreeItemget_prev_visible ( bool wrap=false )
floatget_range ( int column ) const
Dictionaryget_range_config ( int column )
Stringget_suffix ( int column ) const
Stringget_text ( int column ) const
TextAlignget_text_align ( int column ) const
Stringget_tooltip ( int column ) const
boolis_button_disabled ( int column, int button_idx ) const
boolis_checked ( int column ) const
boolis_custom_set_as_button ( int column ) const
boolis_editable ( int column )
boolis_selectable ( int column ) const
boolis_selected ( int column )
voidmove_to_bottom ( )
voidmove_to_top ( )
voidremove_child ( Object child )
voidselect ( int column )
voidset_button ( int column, int button_idx, Texture button )
voidset_button_disabled ( int column, int button_idx, bool disabled )
voidset_cell_mode ( int column, TreeCellMode mode )
voidset_checked ( int column, bool checked )
voidset_custom_as_button ( int column, bool enable )
voidset_custom_bg_color ( int column, Color color, bool just_outline=false )
voidset_custom_color ( int column, Color color )
voidset_custom_draw ( int column, Object object, String callback )
voidset_editable ( int column, bool enabled )
voidset_expand_right ( int column, bool enable )
voidset_icon ( int column, Texture texture )
voidset_icon_max_width ( int column, int width )
voidset_icon_modulate ( int column, Color modulate )
voidset_icon_region ( int column, Rect2 region )
voidset_metadata ( int column, Variant meta )
voidset_range ( int column, float value )
voidset_range_config ( int column, float min, float max, float step, bool expr=false )
voidset_selectable ( int column, bool selectable )
voidset_suffix ( int column, String text )
voidset_text ( int column, String text )
voidset_text_align ( int column, TextAlign text_align )
voidset_tooltip ( int column, String tooltip )

Enumerations

enum TreeCellMode:

  • CELL_MODE_STRING = 0 —- Cell contains a string.
  • CELL_MODE_CHECK = 1 —- Cell can be checked.
  • CELL_MODE_RANGE = 2 —- Cell contains a range.
  • CELL_MODE_ICON = 3 —- Cell contains an icon.
  • CELL_MODE_CUSTOM = 4

enum TextAlign:

  • ALIGN_LEFT = 0 —- Align text to the left. See set_text_align().
  • ALIGN_CENTER = 1 —- Center text. See set_text_align().
  • ALIGN_RIGHT = 2 —- Align text to the right. See set_text_align().

Property Descriptions

Setterset_collapsed(value)
Getteris_collapsed()

If true, the TreeItem is collapsed.


  • int custom_minimum_height
Setterset_custom_minimum_height(value)
Getterget_custom_minimum_height()

The custom minimum height.


  • bool disable_folding
Setterset_disable_folding(value)
Getteris_folding_disabled()

If true, folding is disabled for this TreeItem.

Method Descriptions

Adds a button with Texture button at column column. The button_idx index is used to identify the button when calling other methods. If not specified, the next available index is used, which may be retrieved by calling get_button_count immediately after this method. Optionally, the button can be disabled and have a tooltip.


Calls the method on the actual TreeItem and its children recursively. Pass parameters as a comma separated list.


  • void clear_custom_bg_color ( int column )

Resets the background color for the given column to default.


  • void clear_custom_color ( int column )

Resets the color for the given column to default.


  • void deselect ( int column )

Deselects the given column.


  • void erase_button ( int column, int button_idx )

Removes the button at index button_idx in column column.


Returns the Texture of the button at index button_idx in column column.


  • int get_button_count ( int column ) const

Returns the number of buttons in column column. May be used to get the most recently added button’s index, if no index was specified.


  • String get_button_tooltip ( int column, int button_idx ) const

Returns the tooltip string for the button at index button_idx in column column.


Returns the column’s cell mode.


Returns the TreeItem’s first child item or a null object if there is none.


  • Color get_custom_bg_color ( int column ) const

Returns the custom background color of column column.


  • Color get_custom_color ( int column ) const

Returns the custom color of column column.


  • bool get_expand_right ( int column ) const

Returns true if expand_right is set.


Returns the given column’s icon Texture. Error if no icon is set.


  • int get_icon_max_width ( int column ) const

Returns the column’s icon’s maximum width.


  • Color get_icon_modulate ( int column ) const

Returns the Color modulating the column’s icon.


  • Rect2 get_icon_region ( int column ) const

Returns the icon Texture region as Rect2.



Returns the next TreeItem in the tree or a null object if there is none.


Returns the next visible TreeItem in the tree 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 parent TreeItem or a null object if there is none.


Returns the previous TreeItem in the tree or a null object if there is none.


Returns the previous visible TreeItem in the tree 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 the given column’s text.


Returns the given column’s text alignment.


Returns the given column’s tooltip.


  • bool is_button_disabled ( int column, int button_idx ) const

Returns true if the button at index button_idx for the given column is disabled.


  • bool is_checked ( int column ) const

Returns true if the given column is checked.


  • bool is_custom_set_as_button ( int column ) const

Returns true if column column is editable.


  • bool is_selectable ( int column ) const

Returns true if column column is selectable.


Returns true if column column is selected.


  • void move_to_bottom ( )

Moves this TreeItem to the bottom in the Tree hierarchy.


  • void move_to_top ( )

Moves this TreeItem to the top in the Tree hierarchy.


  • void remove_child ( Object child )

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. To completely remove a TreeItem use Object.free.


  • void select ( int column )

Selects the column column.


Sets the given column’s button Texture at index button_idx to button.


  • void set_button_disabled ( int column, int button_idx, bool disabled )

If true, disables the button at index button_idx in column column.


Sets the given column’s cell mode to mode. See TreeCellMode constants.


  • void set_checked ( int column, bool checked )

If true, the column column is checked.


  • void set_custom_as_button ( int column, bool enable )

  • void set_custom_bg_color ( int column, Color color, bool just_outline=false )

Sets the given column’s custom background color and whether to just use it as an outline.


  • void set_custom_color ( int column, Color color )

Sets the given column’s custom color.


Sets the given column’s custom draw callback to callback method on object.

The callback should accept two arguments: the TreeItem that is drawn and its position and size as a Rect2.


  • void set_editable ( int column, bool enabled )

If true, column column is editable.


  • void set_expand_right ( int column, bool enable )

If true, column column is expanded to the right.


Sets the given column’s icon Texture.


  • void set_icon_max_width ( int column, int width )

Sets the given column’s icon’s maximum width.


  • void set_icon_modulate ( int column, Color modulate )

Modulates the given column’s icon with modulate.


  • void set_icon_region ( int column, Rect2 region )

Sets the given column’s icon’s texture region.



  • void set_range ( int column, float value )


  • void set_selectable ( int column, bool selectable )

If true, the given column is selectable.




Sets the given column’s text alignment. See TextAlign for possible values.


  • void set_tooltip ( int column, String tooltip )

Sets the given column’s tooltip text.