TreeItem¶
Inherits: Object
Control for a single item inside a Tree.
Description¶
Control for a single item inside a Tree. May have child TreeItem
s and be styled as well as contain buttons.
You can remove a TreeItem
by using Object.free.
Properties¶
Methods¶
void |
add_button ( int column, Texture2D button, int id=-1, bool disabled=false, String tooltip="" ) |
call_recursive ( StringName method, ... ) vararg |
|
void |
clear_custom_bg_color ( int column ) |
void |
clear_custom_color ( int column ) |
void |
clear_opentype_features ( int column ) |
create_child ( int idx=-1 ) |
|
void |
|
void |
erase_button ( int column, int button_idx ) |
get_button ( int column, int button_idx ) const |
|
get_button_by_id ( int column, int id ) const |
|
get_button_count ( int column ) const |
|
get_button_id ( int column, int button_idx ) const |
|
get_button_tooltip ( int column, int button_idx ) 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_visible ( bool wrap=false ) |
|
get_opentype_feature ( int column, String tag ) const |
|
get_parent ( ) const |
|
get_prev ( ) |
|
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 ( int column ) const |
|
get_tree ( ) const |
|
is_button_disabled ( int column, int button_idx ) const |
|
is_checked ( int column ) const |
|
is_custom_set_as_button ( 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_button ( int column, int button_idx, Texture2D button ) |
void |
set_button_disabled ( int column, int button_idx, bool disabled ) |
void |
set_cell_mode ( int column, TreeCellMode mode ) |
void |
set_checked ( int column, bool checked ) |
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_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 |
set_opentype_feature ( int column, String tag, int value ) |
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 ( int column, String tooltip ) |
void |
uncollapse_tree ( ) |
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
Property Descriptions¶
bool collapsed
Setter |
set_collapsed(value) |
Getter |
is_collapsed() |
If true
, the TreeItem is collapsed.
int custom_minimum_height
Setter |
set_custom_minimum_height(value) |
Getter |
get_custom_minimum_height() |
The custom minimum height.
bool disable_folding
Setter |
set_disable_folding(value) |
Getter |
is_folding_disabled() |
If true
, folding is disabled for this TreeItem.
Method Descriptions¶
Adds a button with Texture2D 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
.
Variant 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.
void clear_opentype_features ( int column )
Removes all OpenType features.
Creates an item and adds it as a child.
The new item will be inserted as position idx
(the default value -1
means the last position), or it will be the last child if idx
is higher than the child count.
void deselect ( int column )
Deselects the given column.
Removes the button at index button_idx
in column column
.
Returns the Texture2D of the button at index button_idx
in column column
.
Returns the button index if there is a button with id id
in column column
, otherwise returns -1.
Returns the number of buttons in column column
.
Returns the id for the button at index button_idx
in column column
.
Returns the tooltip string for the button at index button_idx
in column column
.
TreeCellMode get_cell_mode ( int column ) const
Returns the column's cell mode.
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.
int get_child_count ( )
Returns the number of child items.
Array get_children ( )
Returns an array of references to the item's children.
Returns the custom background color of column column
.
Returns the custom color of column column
.
Returns custom font used to draw text in the column column
.
Returns custom font size used to draw text in the column column
.
Returns true
if expand_right
is set.
TreeItem get_first_child ( ) const
Returns the TreeItem's first child.
Returns the given column's icon Texture2D. Error if no icon is set.
Returns the column's icon's maximum width.
Returns the Color modulating the column's icon.
Returns the icon Texture2D region as Rect2.
int get_index ( )
Returns the node's order in the tree. For example, if called on the first child item the position is 0
.
Returns item's text language code.
Returns the metadata value that was set for the given column using set_metadata.
TreeItem get_next ( ) const
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 OpenType feature tag
of the item's text.
TreeItem get_parent ( ) const
Returns the parent TreeItem or a null object if there is none.
TreeItem get_prev ( )
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 value of a CELL_MODE_RANGE column.
Dictionary get_range_config ( int column )
Returns a dictionary containing the range parameters for a given column. The keys are "min", "max", "step", and "expr".
StructuredTextParser get_structured_text_bidi_override ( int column ) const
Gets the suffix string shown after the column value.
Returns the given column's text.
HorizontalAlignment get_text_alignment ( int column ) const
Returns the given column's text alignment.
TextDirection get_text_direction ( int column ) const
Returns item's text base writing direction.
Returns the given column's tooltip.
Tree get_tree ( ) const
Returns the Tree that owns this TreeItem.
Returns true
if the button at index button_idx
for the given column is disabled.
Returns true
if the given column is checked.
Returns true
if column column
is editable.
Returns true
if the given column is indeterminate.
Returns true
if column column
is selectable.
Returns true
if column column
is selected.
void move_after ( TreeItem item )
Moves this TreeItem right after the given item
.
Note: You can't move to the root or move the root.
void move_before ( TreeItem item )
Moves this TreeItem right before the given item
.
Note: You can't move to the root or move the root.
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.
void remove_child ( TreeItem 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 Texture2D at index button_idx
to button
.
If true
, disables the button at index button_idx
in column column
.
void set_cell_mode ( int column, TreeCellMode mode )
Sets the given column's cell mode to mode
. See TreeCellMode constants.
If true
, the column column
is checked. Clears column's indeterminate status.
Sets the given column's custom background color and whether to just use it as an outline.
Sets the given column's custom color.
void set_custom_draw ( int column, Object object, StringName 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 Rect2.
Sets custom font used to draw text in the column column
.
Sets custom font size used to draw text in the column column
.
If true
, column column
is editable.
If true
, column column
is expanded to the right.
Sets the given column's icon Texture2D.
Sets the given column's icon's maximum width.
Modulates the given column's icon with modulate
.
Sets the given column's icon's texture region.
If true
, the column column
is marked indeterminate.
Note: If set true
from false
, then column is cleared of checked status.
Sets language code of item's text used for line-breaking and text shaping algorithms, if left empty current locale is used instead.
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 OpenType feature tag
for the item's text.
Sets the value of a CELL_MODE_RANGE column.
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.
If true
, the given column is selectable.
void set_structured_text_bidi_override ( int column, StructuredTextParser parser )
Sets a string to be shown after a column's value (for example, a unit abbreviation).
Sets the given column's text value.
void set_text_alignment ( int column, HorizontalAlignment text_alignment )
Sets the given column's text alignment. See HorizontalAlignment for possible values.
void set_text_direction ( int column, TextDirection direction )
Sets item's text base writing direction.
Sets the given column's tooltip text.
void uncollapse_tree ( )