TreeItem

    Control for a single item inside a Tree.

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

    You can remove a TreeItem by using .

    Properties

    Enumerations

    enum TreeCellMode:

    • CELL_MODE_STRING = 0 —- Cell contains a string.

    • CELL_MODE_CHECK = 1 —- Cell contains a checkbox.

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


    • custom_minimum_height

    The custom minimum height.


    • bool disable_folding

    If true, folding is disabled for this TreeItem.

    Method Descriptions

    • void add_button ( int column, button, int id=-1, disabled=false, String tooltip=”” )

    Adds a button with button at column column. The id is used to identify the button. 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.


    • call_recursive ( String method, … ) vararg

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


    • void clear_custom_bg_color ( 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 ( column )

    Deselects the given column.


    • void erase_button ( int column, button_idx )

    Removes the button at index button_idx in column column.


    • Texture get_button ( column, int button_idx ) const

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


    • int get_button_by_id ( column, int id ) const

    Returns the button index if there is a button with id id in column column, otherwise returns -1.


    • get_button_count ( int column ) const

    Returns the number of buttons in column column.


    Returns the id for the button at index button_idx in column .


    • get_button_tooltip ( int column, 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.


    • get_custom_bg_color ( int column ) const

    Returns the custom background color of column column.


    • get_custom_color ( int column ) const

    Returns the custom color of column column.


    • get_expand_right ( int column ) const

    Returns true if expand_right is set.


    • get_icon ( int column ) const

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


    • int get_icon_max_width ( column ) const

    Returns the column’s icon’s maximum width.


    • Color get_icon_modulate ( column ) const

    Returns the Color modulating the column’s icon.


    • get_icon_region ( int column ) const

    Returns the icon region as Rect2.


    • get_metadata ( int column ) const

    Returns the metadata value that was set for the given column using .


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


    • get_next_visible ( bool wrap=false )

    Returns the next visible sibling 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.


    • get_parent ( )

    Returns the parent TreeItem or a null object if there is none.


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


    • get_prev_visible ( bool wrap=false )

    Returns the previous visible sibling 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.


    • get_range ( int column ) const

    Returns the value of a column.


    Returns a dictionary containing the range parameters for a given column. The keys are “min”, “max”, “step”, and “expr”.


    • String get_suffix ( column ) const

    Gets the suffix string shown after the column value.


    • String get_text ( column ) const

    Returns the given column’s text.


    Returns the given column’s text alignment.


    • String get_tooltip ( column ) const

    Returns the given column’s tooltip.


    • bool is_button_disabled ( column, int button_idx ) const

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


    • is_checked ( int column ) const

    Returns true if the given column is checked.


    • is_custom_set_as_button ( int column ) const

    • is_editable ( int column )

    Returns true if column column is editable.


    Returns true if column column is selectable.


    • is_selected ( int column )

    Returns true if column column is selected.


    • void move_to_bottom ( )

    Moves this TreeItem to the bottom in the hierarchy.


    • void move_to_top ( )

    Moves this TreeItem to the top in the Tree hierarchy.


    • void remove_child ( 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 use .


    • void select ( int column )

    Selects the column column.


    • void set_button ( column, int button_idx, button )

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


    • void set_button_disabled ( column, int button_idx, disabled )

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


    • void set_cell_mode ( int column, mode )

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


    • void set_checked ( column, bool checked )

    If true, the column column is checked.


    • void set_custom_as_button ( column, bool enable )

    • void set_custom_bg_color ( column, Color color, 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 )

    Sets the given column’s custom color.


    • void set_custom_draw ( int column, object, String callback )

    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 .


    • void set_editable ( int column, enabled )

    If true, column column is editable.


    • void set_expand_right ( int column, enable )

    If true, column column is expanded to the right.


    • void set_icon ( int column, texture )

    Sets the given column’s icon Texture.


    • void set_icon_max_width ( column, int width )

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


    • void set_icon_modulate ( column, Color modulate )

    Modulates the given column’s icon with modulate.


    • void set_icon_region ( column, Rect2 region )

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


    • void set_metadata ( column, Variant meta )

    Sets the metadata value for the given column, which can be retrieved later using . This can be used, for example, to store a reference to the original data.


    • void set_range ( int column, value )

    Sets the value of a CELL_MODE_RANGE column.


    • void set_range_config ( column, float min, max, float step, expr=false )

    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 .


    • void set_selectable ( int column, selectable )

    If , the given column is selectable.


    • void set_suffix ( int column, text )

    Sets a string to be shown after a column’s value (for example, a unit abbreviation).


    • void set_text ( int column, text )

    Sets the given column’s text value.


    • void set_text_align ( int column, text_align )

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