class-description NEWS COMMUNITY STORE TUTORIALS SIGN UP LOGIN LOGOUT ROKOJORI NEWSLETTER SIGN UP LOGIN LOGOUT NEWS COMMUNITY STORE TUTORIALS TOGGLE FULLSCREEN VOLLBILD AN/AUS ObjectNodeCanvasItemControl Tree
A control used to show a set of internal TreeItems in a hierarchical structure.
A control used to show a set of internal TreeItems in a hierarchical structure. The tree items can be selected, expanded and collapsed. The tree can have multiple columns with custom controls like LineEdits, buttons and popups. It can be useful for structured displays and interactions.
Trees are built via code, using TreeItem objects to create the structure. They have a single root, but multiple roots can be simulated with hide_root:
func _ready(): var tree = Tree.new() var root = tree.create_item() tree.hide_root = true var child1 = tree.create_item(root) var child2 = tree.create_item(root) var subchild1 = tree.create_item(child1) subchild1.set_text(0, "Subchild1")
public override void _Ready() { var tree = new Tree(); TreeItem root = tree.CreateItem(); tree.HideRoot = true; TreeItem child1 = tree.CreateItem(root); TreeItem child2 = tree.CreateItem(root); TreeItem subchild1 = tree.CreateItem(child1); subchild1.SetText(0, "Subchild1"); }

To iterate over all the TreeItem objects in a Tree object, use [method TreeItem.get_next] and [method TreeItem.get_first_child] after getting the root through get_root. You can use [method Object.free] on a TreeItem to remove it from the Tree.
Incremental search: Like ItemList and PopupMenu, Tree supports searching within the list while the control is focused. Press a key that matches the first letter of an item's name to select the first item starting with the given letter. After that point, there are two ways to perform incremental search: 1) Press the same key again before the timeout duration to select the next item starting with the same letter. 2) Press letter keys that match the rest of the word before the timeout duration to match to select the item in question directly. Both of these actions will be reset to the beginning of the list if the timeout duration has passed since the last keystroke was registered. You can adjust the timeout duration by changing [member ProjectSettings.gui/timers/incremental_search_max_interval_msec].
Enum SelectMode<>():Enum

SELECT_SINGLE:null = 0
Allows selection of a single cell at a time. From the perspective of items, only a single item is allowed to be selected. And there is only one column selected in the selected item.
The focus cursor is always hidden in this mode, but it is positioned at the current selection, making the currently selected item the currently focused item.


SELECT_ROW:null = 1
Allows selection of a single row at a time. From the perspective of items, only a single items is allowed to be selected. And all the columns are selected in the selected item.
The focus cursor is always hidden in this mode, but it is positioned at the first column of the current selection, making the currently selected item the currently focused item.


SELECT_MULTI:null = 2
Allows selection of multiple cells at the same time. From the perspective of items, multiple items are allowed to be selected. And there can be multiple columns selected in each selected item.
The focus cursor is visible in this mode, the item or column under the cursor is not necessarily selected.
Enum DropModeFlags<>():Enum

DROP_MODE_DISABLED:null = 0
Disables all drop sections, but still allows to detect the "on item" drop section by get_drop_section_at_position.
Note: This is the default flag, it has no effect when combined with other flags.


DROP_MODE_ON_ITEM:null = 1
Enables the "on item" drop section. This drop section covers the entire item.
When combined with DROP_MODE_INBETWEEN, this drop section halves the height and stays centered vertically.


DROP_MODE_INBETWEEN:null = 2
Enables "above item" and "below item" drop sections. The "above item" drop section covers the top half of the item, and the "below item" drop section covers the bottom half.
When combined with DROP_MODE_ON_ITEM, these drop sections halves the height and stays on top / bottom accordingly.
Signal button_clicked<>( TreeItem item=, item:TreeItem=, int column=, column:int=, int id=, id:int=, int mouse_button_index=, mouse_button_index:int=, ):Signal
Emitted when a button on the tree was pressed (see [method TreeItem.add_button]).

Signal cell_selected<>():Signal
Emitted when a cell is selected.

Signal check_propagated_to_item<>( TreeItem item=, item:TreeItem=, int column=, column:int=, ):Signal
Emitted when [method TreeItem.propagate_check] is called. Connect to this signal to process the items that are affected when [method TreeItem.propagate_check] is invoked. The order that the items affected will be processed is as follows: the item that invoked the method, children of that item, and finally parents of that item.

Signal column_title_clicked<>( int column=, column:int=, int mouse_button_index=, mouse_button_index:int=, ):Signal
Emitted when a column's title is clicked with either MOUSE_BUTTON_LEFT or MOUSE_BUTTON_RIGHT.

Signal custom_item_clicked<>( int mouse_button_index=, mouse_button_index:int=, ):Signal
Emitted when an item with [constant TreeItem.CELL_MODE_CUSTOM] is clicked with a mouse button.

Signal custom_popup_edited<>( bool arrow_clicked=, arrow_clicked:bool=, ):Signal
Emitted when a cell with the [constant TreeItem.CELL_MODE_CUSTOM] is clicked to be edited.

Signal empty_clicked<>( Vector2 click_position=, click_position:Vector2=, int mouse_button_index=, mouse_button_index:int=, ):Signal
Emitted when a mouse button is clicked in the empty space of the tree.

Signal item_activated<>():Signal
Emitted when an item is double-clicked, or selected with a ui_accept input event (e.g. using kbdEnter[/kbd] or kbdSpace[/kbd] on the keyboard).

Signal item_collapsed<>( TreeItem item=, item:TreeItem=, ):Signal
Emitted when an item is expanded or collapsed by clicking on the folding arrow or through code.

Note: Despite its name, this signal is also emitted when an item is expanded.
Signal item_edited<>():Signal
Emitted when an item is edited.

Signal item_icon_double_clicked<>():Signal
Emitted when an item's icon is double-clicked. For a signal that emits when any part of the item is double-clicked, see item_activated.

Signal item_mouse_selected<>( Vector2 mouse_position=, mouse_position:Vector2=, int mouse_button_index=, mouse_button_index:int=, ):Signal
Emitted when an item is selected with a mouse button.

Signal item_selected<>():Signal
Emitted when an item is selected.

Signal multi_selected<>( TreeItem item=, item:TreeItem=, int column=, column:int=, bool selected=, selected:bool=, ):Signal
Emitted instead of item_selected if select_mode is set to SELECT_MULTI.

Signal nothing_selected<>():Signal
Emitted when a left mouse button click does not select any item.

set get bool allow_reselect<>():bool set get
If true, the currently selected cell may be selected again.

set get bool allow_rmb_select<>():bool set get
If true, a right mouse button click can select items.

set get bool allow_search<>():bool set get
If true, allows navigating the Tree with letter keys through incremental search.

set get bool auto_tooltip<>():bool set get
If true, tree items with no tooltip assigned display their text as their tooltip. See also [method TreeItem.get_tooltip_text] and [method TreeItem.get_button_tooltip_text].

set get bool clip_contents<>():bool set get
set get bool column_titles_visible<>():bool set get
If true, column titles are visible.

set get int columns<>():int set get
The number of columns.

set get int drop_mode_flags<>():int set get
The drop mode as an OR combination of flags. See DropModeFlags constants. Once dropping is done, reverts to DROP_MODE_DISABLED. Setting this during [method Control._can_drop_data] is recommended.

This controls the drop sections, i.e. the decision and drawing of possible drop locations based on the mouse position.
set get bool enable_drag_unfolding<>():bool set get
If true, tree items will unfold when hovered over during a drag-and-drop. The delay for when this happens is dictated by dragging_unfold_wait_msec.

set get bool enable_recursive_folding<>():bool set get
If true, recursive folding is enabled for this Tree. Holding down kbdShift[/kbd] while clicking the fold arrow or using ui_right/ui_left shortcuts collapses or uncollapses the TreeItem and all its descendants.

set get int focus_mode<>():int set get
set get bool hide_folding<>():bool set get
If true, the folding arrow is hidden.

set get bool hide_root<>():bool set get
If true, the tree's root is hidden.

set get bool scroll_horizontal_enabled<>():bool set get
If true, enables horizontal scrolling.

set get bool scroll_vertical_enabled<>():bool set get
If true, enables vertical scrolling.

set get int select_mode<>():int set get
Allows single or multiple selection. See the SelectMode constants.

void clear<>():void
Clears the tree. This removes all items.

TreeItem create_item<>( TreeItem parent=null, parent:TreeItem=null, int index=-1, index:int=-1, ):TreeItem
Creates an item in the tree and adds it as a child of parent, which can be either a valid TreeItem or null.

If parent is null, the root item will be the parent, or the new item will be the root itself if the tree is empty.
The new item will be the index-th child of parent, or it will be the last child if there are not enough siblings.
void deselect_all<>():void
Deselects all tree items (rows and columns). In SELECT_MULTI mode also removes selection cursor.

bool edit_selected<>( bool force_edit=false, force_edit:bool=false, ):bool
Edits the selected tree item as if it was clicked.

Either the item must be set editable with [method TreeItem.set_editable] or force_edit must be true.
Returns true if the item could be edited. Fails if no item is selected.
void ensure_cursor_is_visible<>():void
Makes the currently focused cell visible.

This will scroll the tree if necessary. In SELECT_ROW mode, this will not do horizontal scrolling, as all the cells in the selected row is focused logically.
Note: Despite the name of this method, the focus cursor itself is only visible in SELECT_MULTI mode.
int get_button_id_at_position<>( Vector2 position=, position:Vector2=, ):int
Returns the button ID at position, or -1 if no button is there.

int get_column_at_position<>( Vector2 position=, position:Vector2=, ):int
Returns the column index at position, or -1 if no item is there.

int get_column_expand_ratio<>( int column=, column:int=, ):int
Returns the expand ratio assigned to the column.

String get_column_title<>( int column=, column:int=, ):String
Returns the column's title.

int get_column_title_alignment<>( int column=, column:int=, ):int
Returns the column title alignment.

int get_column_title_direction<>( int column=, column:int=, ):int
Returns column title base writing direction.

String get_column_title_language<>( int column=, column:int=, ):String
Returns column title language code.

String get_column_title_tooltip_text<>( int column=, column:int=, ):String
Returns the column title's tooltip text.

int get_column_width<>( int column=, column:int=, ):int
Returns the column's width in pixels.

Rect2 get_custom_popup_rect<>():Rect2
Returns the rectangle for custom popups. Helper to create custom cell controls that display a popup. See [method TreeItem.set_cell_mode].

int get_drop_section_at_position<>( Vector2 position=, position:Vector2=, ):int
Returns the drop section at position, or -100 if no item is there.

Values -1, 0, or 1 will be returned for the "above item", "on item", and "below item" drop sections, respectively. See DropModeFlags for a description of each drop section.
To get the item which the returned drop section is relative to, use get_item_at_position.
TreeItem get_edited<>():TreeItem
Returns the currently edited item. Can be used with item_edited to get the item that was modified.

func _ready(): $Tree.item_edited.connect(on_Tree_item_edited) func on_Tree_item_edited(): print($Tree.get_edited()) # This item just got edited (e.g. checked).
public override void _Ready() { GetNode<Tree>("Tree").ItemEdited += OnTreeItemEdited; } public void OnTreeItemEdited() { GD.Print(GetNode<Tree>("Tree").GetEdited()); // This item just got edited (e.g. checked). }

int get_edited_column<>():int
Returns the column for the currently edited item.

Rect2 get_item_area_rect<>( TreeItem item=, item:TreeItem=, int column=-1, column:int=-1, int button_index=-1, button_index:int=-1, ):Rect2
Returns the rectangle area for the specified TreeItem. If column is specified, only get the position and size of that column, otherwise get the rectangle containing all columns. If a button index is specified, the rectangle of that button will be returned.

TreeItem get_item_at_position<>( Vector2 position=, position:Vector2=, ):TreeItem
Returns the tree item at the specified position (relative to the tree origin position).

TreeItem get_next_selected<>( TreeItem from=, from:TreeItem=, ):TreeItem
Returns the next selected TreeItem after the given one, or null if the end is reached.

If from is null, this returns the first selected item.
int get_pressed_button<>():int
Returns the last pressed button's index.

TreeItem get_root<>():TreeItem
Returns the tree's root item, or null if the tree is empty.

Vector2 get_scroll<>():Vector2
Returns the current scrolling position.

TreeItem get_selected<>():TreeItem
Returns the currently focused item, or null if no item is focused.

In SELECT_ROW and SELECT_SINGLE modes, the focused item is same as the selected item. In SELECT_MULTI mode, the focused item is the item under the focus cursor, not necessarily selected.
To get the currently selected item(s), use get_next_selected.
int get_selected_column<>():int
Returns the currently focused column, or -1 if no column is focused.

In SELECT_SINGLE mode, the focused column is the selected column. In SELECT_ROW mode, the focused column is always 0 if any item is selected. In SELECT_MULTI mode, the focused column is the column under the focus cursor, and there are not necessarily any column selected.
To tell whether a column of an item is selected, use [method TreeItem.is_selected].
bool is_column_clipping_content<>( int column=, column:int=, ):bool
Returns true if the column has enabled clipping (see set_column_clip_content).

bool is_column_expanding<>( int column=, column:int=, ):bool
Returns true if the column has enabled expanding (see set_column_expand).

void scroll_to_item<>( TreeItem item=, item:TreeItem=, bool center_on_item=false, center_on_item:bool=false, ):void
Causes the Tree to jump to the specified TreeItem.

void set_column_clip_content<>( int column=, column:int=, bool enable=, enable:bool=, ):void
Allows to enable clipping for column's content, making the content size ignored.

void set_column_custom_minimum_width<>( int column=, column:int=, int min_width=, min_width:int=, ):void
Overrides the calculated minimum width of a column. It can be set to 0 to restore the default behavior. Columns that have the "Expand" flag will use their "min_width" in a similar fashion to [member Control.size_flags_stretch_ratio].

void set_column_expand<>( int column=, column:int=, bool expand=, expand:bool=, ):void
If true, the column will have the "Expand" flag of Control. Columns that have the "Expand" flag will use their expand ratio in a similar fashion to [member Control.size_flags_stretch_ratio] (see set_column_expand_ratio).

void set_column_expand_ratio<>( int column=, column:int=, int ratio=, ratio:int=, ):void
Sets the relative expand ratio for a column. See set_column_expand.

void set_column_title<>( int column=, column:int=, String title=, title:String=, ):void
Sets the title of a column.

void set_column_title_alignment<>( int column=, column:int=, int title_alignment=, title_alignment:int=, ):void
Sets the column title alignment. Note that [constant @GlobalScope.HORIZONTAL_ALIGNMENT_FILL] is not supported for column titles.

void set_column_title_direction<>( int column=, column:int=, int direction=, direction:int=, ):void
Sets column title base writing direction.

void set_column_title_language<>( int column=, column:int=, String language=, language:String=, ):void
Sets language code of column title used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

void set_column_title_tooltip_text<>( int column=, column:int=, String tooltip_text=, tooltip_text:String=, ):void
Sets the column title's tooltip text.

void set_selected<>( TreeItem item=, item:TreeItem=, int column=, column:int=, ):void
Selects the specified TreeItem and column.




All social media brands are registrated trademarks and belong to their respective owners.





CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
CONTACT IMPRINT TERMS OF USE PRIVACY © ROKOROJI ® 2021 rokojori.com
We are using cookies on this site. Read more... Wir benutzen Cookies auf dieser Seite. Mehr lesen...