Tree
Category: Core
Control to show a tree of items.
Properties
Methods
are_column_titles_visible ( ) const | |
void | ( ) |
TreeItem | ( Object parent=null, idx=-1 ) |
void | ensure_cursor_is_visible ( ) |
get_column_at_position ( position ) const | |
String | ( int column ) const |
get_column_width ( column ) const | |
Rect2 | ( ) const |
int | ( Vector2 position ) const |
get_edited ( ) const | |
get_edited_column ( ) const | |
get_item_area_rect ( item, int column=-1 ) const | |
get_item_at_position ( position ) const | |
TreeItem | ( Object from ) |
get_pressed_button ( ) const | |
get_root ( ) | |
get_scroll ( ) const | |
get_selected ( ) const | |
get_selected_column ( ) const | |
void | ( int column, expand ) |
void | set_column_min_width ( column, int min_width ) |
void | ( int column, title ) |
void | set_column_titles_visible ( visible ) |
Texture | arrow |
arrow_collapsed | |
StyleBox | bg |
bg_focus | |
int | button_margin |
button_pressed | |
Texture | checked |
cursor | |
Color | cursor_color |
cursor_unfocused | |
StyleBox | custom_button |
custom_button_font_highlight | |
StyleBox | custom_button_hover |
custom_button_pressed | |
int | draw_guides |
draw_relationship_lines | |
Color | drop_position_color |
font | |
Color | font_color |
font_color_selected | |
Color | guide_color |
guide_width | |
int | hseparation |
item_margin | |
Color | relationship_line_color |
scroll_border | |
int | scroll_speed |
select_arrow | |
StyleBox | selected |
selected_focus | |
Color | selection_color |
title_button_color | |
Font | title_button_font |
title_button_hover | |
StyleBox | title_button_normal |
title_button_pressed | |
Texture | unchecked |
updown | |
int | vseparation |
Signals
- button_pressed ( item, int column, id )
Emitted when a button on the tree was pressed (see TreeItem.add_button).
- cell_selected ( )
Emitted when a cell is selected.
- column_title_pressed ( column )
Emitted when a column’s title is pressed.
- custom_popup_edited ( bool arrow_clicked )
Emitted when a cell with the is clicked to be edited.
- empty_tree_rmb_selected ( Vector2 position )
Emitted when the right mouse button is pressed if RMB selection is active and the tree is empty.
- item_activated ( )
Emitted when an item’s label is double-clicked.
- item_collapsed ( item )
Emitted when an item is collapsed by a click on the folding arrow.
- item_custom_button_pressed ( )
- item_double_clicked ( )
Emitted when an item’s icon is double-clicked.
- item_edited ( )
Emitted when an item is edited.
Emitted when an item is edited using the right mouse button.
- item_rmb_selected ( Vector2 position )
Emitted when an item is selected with the right mouse button.
- item_selected ( )
Emitted when an item is selected.
- multi_selected ( item, int column, selected )
Emitted instead of when select_mode
is SELECT_MULTI.
- nothing_selected ( )
Enumerations
enum SelectMode:
- SELECT_SINGLE = 0 — Allow selection of a single item at a time.
- SELECT_ROW = 1
- SELECT_MULTI = 2 — Allow selection of multiple items at the same time.
- DROP_MODE_DISABLED = 0
- DROP_MODE_ON_ITEM = 1
- DROP_MODE_INBETWEEN = 2
This shows a tree of items that can be selected, expanded and collapsed. The tree can have multiple columns with custom controls like text editing, buttons and popups. It can be useful for structured displays and interactions.
Trees are built via code, using objects to create the structure. They have a single root but multiple roots can be simulated if a dummy hidden root is added.
Property Descriptions
- bool allow_reselect
If true
, the currently selected cell may be selected again.
- allow_rmb_select
Setter | set_allow_rmb_select(value) |
Getter | get_allow_rmb_select() |
If true
, a right mouse button click can select items.
- int columns
Setter | set_columns(value) |
Getter | get_columns() |
The amount of columns.
- drop_mode_flags
The drop mode as an OR combination of flags. See constants. Once dropping is done, reverts to DROP_MODE_DISABLED. Setting this during is recommended.
- bool hide_folding
Setter | set_hide_folding(value) |
Getter | is_folding_hidden() |
If true
, the folding arrow is hidden.
- hide_root
Setter | set_hide_root(value) |
Getter | is_root_hidden() |
If true
, the tree’s root is hidden.
- SelectMode select_mode
Allow single or multiple selection. See the SELECT_*
constants.
Method Descriptions
- are_column_titles_visible ( ) const
Returns if the column titles are being shown.
- void clear ( )
Clears the tree. This removes all items.
Create an item in the tree and add it as the last child of parent
. If parent is not given, it will be added as the root’s last child, or it’ll the be the root itself if the tree is empty.
- void ensure_cursor_is_visible ( )
Makes the currently selected item visible. This will scroll the tree to make sure the selected item is visible.
- int get_column_at_position ( position ) const
Returns the column index under the given point.
- String get_column_title ( column ) const
Returns the column’s title.
- int get_column_width ( column ) const
Returns the column’s width in pixels.
- Rect2 get_custom_popup_rect ( ) const
- get_drop_section_at_position ( Vector2 position ) const
If includes DROP_MODE_INBETWEEN, returns -1 if position
is the upper part of a tree item at that position, 1 for the lower part, and additionally 0 for the middle part if includes DROP_MODE_ON_ITEM.
Otherwise, returns 0. If there are no tree item at position
, returns -100.
- get_edited ( ) const
Returns the currently edited item. This is only available for custom cell mode.
- int get_edited_column ( ) const
Returns the column for the currently edited item. This is only available for custom cell mode.
- get_item_area_rect ( Object item, column=-1 ) const
Returns the rectangle area for the specified item. If column is specified, only get the position and size of that column, otherwise get the rectangle containing all columns.
- TreeItem get_item_at_position ( position ) const
Returns the tree item at the specified position (relative to the tree origin position).
- TreeItem get_next_selected ( from )
Returns the next selected item after the given one.
- int get_pressed_button ( ) const
Returns the last pressed button’s index.
- get_root ( )
Returns the tree’s root item.
- Vector2 get_scroll ( ) const
Returns the current scrolling position.
- get_selected ( ) const
Returns the currently selected item.
- int get_selected_column ( ) const
Returns the current selection’s column.
- void set_column_expand ( column, bool expand )
If , the column will have the “Expand” flag of . Columns that have the “Expand” flag will use their “min_width” in a similar fashion to Control.size_flags_stretch_ratio.
- void set_column_min_width ( column, int min_width )
Sets the minimum width of a column. Columns that have the “Expand” flag will use their “min_width” in a similar fashion to .
- void set_column_title ( int column, title )
Set the title of a column.
If true
, column titles are visible.