Up to date
This page is up to date for Godot 4.1
.
If you still find outdated information, please open an issue.
TreeItem¶
Inherits: Object
An internal control for a single item inside Tree.
Description¶
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
.
Properties¶
Methods¶
void |
add_button ( int column, Texture2D button, int id=-1, bool disabled=false, String tooltip_text="" ) |
void |
|
void |
call_recursive ( StringName method, ... ) vararg |
void |
clear_custom_bg_color ( int column ) |
void |
clear_custom_color ( int column ) |
create_child ( int index=-1 ) |
|
void |
|
void |
erase_button ( int column, int button_index ) |
get_autowrap_mode ( int column ) const |
|
get_button ( int column, int button_index ) const |
|
get_button_by_id ( int column, int id ) const |
|
get_button_count ( int column ) const |
|
get_button_id ( int column, int button_index ) const |
|
get_button_tooltip_text ( int column, int button_index ) const |
|
get_cell_mode ( int column ) const |
|
get_child_count ( ) |
|
get_children ( ) |
|
get_custom_bg_color ( int column ) const |
|
get_custom_color ( int column ) const |
|
get_custom_font ( int column ) const |
|
get_custom_font_size ( int column ) const |
|
get_expand_right ( int column ) const |
|
get_first_child ( ) const |
|
get_icon_max_width ( int column ) const |
|
get_icon_modulate ( int column ) const |
|
get_icon_region ( int column ) const |
|
get_index ( ) |
|
get_language ( int column ) const |
|
get_metadata ( int column ) const |
|
get_next ( ) const |
|
get_next_in_tree ( bool wrap=false ) |
|
get_next_visible ( bool wrap=false ) |
|
get_parent ( ) const |
|
get_prev ( ) |
|
get_prev_in_tree ( bool wrap=false ) |
|
get_prev_visible ( bool wrap=false ) |
|
get_range_config ( int column ) |
|
get_structured_text_bidi_override ( int column ) const |
|
get_structured_text_bidi_override_options ( int column ) const |
|
get_suffix ( int column ) const |
|
get_text_alignment ( int column ) const |
|
get_text_direction ( int column ) const |
|
get_tooltip_text ( int column ) const |
|
get_tree ( ) const |
|
is_any_collapsed ( bool only_visible=false ) |
|
is_button_disabled ( int column, int button_index ) const |
|
is_checked ( int column ) const |
|
is_custom_set_as_button ( int column ) const |
|
is_edit_multiline ( int column ) const |
|
is_editable ( int column ) |
|
is_indeterminate ( int column ) const |
|
is_selectable ( int column ) const |
|
is_selected ( int column ) |
|
void |
move_after ( TreeItem item ) |
void |
move_before ( TreeItem item ) |
void |
propagate_check ( int column, bool emit_signal=true ) |
void |
remove_child ( TreeItem child ) |
void |
|
void |
set_autowrap_mode ( int column, AutowrapMode autowrap_mode ) |
void |
set_button ( int column, int button_index, Texture2D button ) |
void |
set_button_color ( int column, int button_index, Color color ) |
void |
set_button_disabled ( int column, int button_index, bool disabled ) |
void |
set_cell_mode ( int column, TreeCellMode mode ) |
void |
set_checked ( int column, bool checked ) |
void |
set_collapsed_recursive ( bool enable ) |
void |
set_custom_as_button ( int column, bool enable ) |
void |
set_custom_bg_color ( int column, Color color, bool just_outline=false ) |
void |
set_custom_color ( int column, Color color ) |
void |
set_custom_draw ( int column, Object object, StringName callback ) |
void |
set_custom_font ( int column, Font font ) |
void |
set_custom_font_size ( int column, int font_size ) |
void |
set_edit_multiline ( int column, bool multiline ) |
void |
set_editable ( int column, bool enabled ) |
void |
set_expand_right ( int column, bool enable ) |
void |
|
void |
set_icon_max_width ( int column, int width ) |
void |
set_icon_modulate ( int column, Color modulate ) |
void |
set_icon_region ( int column, Rect2 region ) |
void |
set_indeterminate ( int column, bool indeterminate ) |
void |
set_language ( int column, String language ) |
void |
set_metadata ( int column, Variant meta ) |
void |
|
void |
set_range_config ( int column, float min, float max, float step, bool expr=false ) |
void |
set_selectable ( int column, bool selectable ) |
void |
set_structured_text_bidi_override ( int column, StructuredTextParser parser ) |
void |
set_structured_text_bidi_override_options ( int column, Array args ) |
void |
set_suffix ( int column, String text ) |
void |
|
void |
set_text_alignment ( int column, HorizontalAlignment text_alignment ) |
void |
set_text_direction ( int column, TextDirection direction ) |
void |
set_tooltip_text ( int column, String tooltip ) |
void |
uncollapse_tree ( ) |
Enumerations¶
enum TreeCellMode:
TreeCellMode CELL_MODE_STRING = 0
Cell contains a string.
TreeCellMode CELL_MODE_CHECK = 1
Cell contains a checkbox.
TreeCellMode CELL_MODE_RANGE = 2
Cell contains a range.
TreeCellMode CELL_MODE_ICON = 3
Cell contains an icon.
TreeCellMode CELL_MODE_CUSTOM = 4
Property Descriptions¶
bool collapsed
If true
, the TreeItem is collapsed.
int custom_minimum_height
The custom minimum height.
bool disable_folding
If true
, folding is disabled for this TreeItem.
bool visible
If true
, the TreeItem is visible (default).
Note that if a TreeItem is set to not be visible, none of its children will be visible either.
Method Descriptions¶
void add_button ( int column, Texture2D button, int id=-1, bool disabled=false, String tooltip_text="" )
Adds a button with Texture2D button
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
.
void add_child ( TreeItem child )
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.
void call_recursive ( StringName 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 ( 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.
TreeItem create_child ( int index=-1 )
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.
void deselect ( int column )
Deselects the given column.
void erase_button ( int column, int button_index )
Removes the button at index button_index
in column column
.
AutowrapMode get_autowrap_mode ( int column ) const
Returns the text autowrap mode in the given column
. By default it is TextServer.AUTOWRAP_OFF.
Texture2D get_button ( int column, int button_index ) const
Returns the Texture2D of the button at index button_index
in column column
.
int get_button_by_id ( int column, int id ) const
Returns the button index if there is a button with ID id
in column column
, otherwise returns -1.
int get_button_count ( int column ) const
Returns the number of buttons in column