mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Sync classref with current source
Changes order of brief/long descriptions and removes category as per godotengine/godot#35132.
This commit is contained in:
@@ -11,13 +11,28 @@ Tree
|
||||
|
||||
**Inherits:** :ref:`Control<class_Control>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
||||
|
||||
**Category:** Core
|
||||
|
||||
Brief Description
|
||||
-----------------
|
||||
|
||||
Control to show a tree of items.
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
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 :ref:`TreeItem<class_TreeItem>` objects to create the structure. They have a single root but multiple roots can be simulated if a dummy hidden root is added.
|
||||
|
||||
::
|
||||
|
||||
func _ready():
|
||||
var tree = Tree.new()
|
||||
var root = tree.create_item()
|
||||
tree.set_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")
|
||||
|
||||
To iterate over all the :ref:`TreeItem<class_TreeItem>` objects in a ``Tree`` object, use :ref:`TreeItem.get_next<class_TreeItem_method_get_next>` and :ref:`TreeItem.get_children<class_TreeItem_method_get_children>` after getting the root through :ref:`get_root<class_Tree_method_get_root>`.
|
||||
|
||||
Properties
|
||||
----------
|
||||
|
||||
@@ -212,6 +227,8 @@ Emitted when a cell with the :ref:`TreeItem.CELL_MODE_CUSTOM<class_TreeItem_cons
|
||||
|
||||
- **empty_rmb** **(** :ref:`Vector2<class_Vector2>` position **)**
|
||||
|
||||
Emitted when the right mouse button is pressed in the empty space of the tree.
|
||||
|
||||
----
|
||||
|
||||
.. _class_Tree_signal_empty_tree_rmb_selected:
|
||||
@@ -296,6 +313,8 @@ Emitted instead of ``item_selected`` if ``select_mode`` is :ref:`SELECT_MULTI<cl
|
||||
|
||||
- **nothing_selected** **(** **)**
|
||||
|
||||
Emitted when a left mouse button click does not select any item.
|
||||
|
||||
Enumerations
|
||||
------------
|
||||
|
||||
@@ -309,11 +328,17 @@ Enumerations
|
||||
|
||||
enum **SelectMode**:
|
||||
|
||||
- **SELECT_SINGLE** = **0** --- Allows selection of a single item at a time.
|
||||
- **SELECT_SINGLE** = **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.
|
||||
|
||||
- **SELECT_ROW** = **1**
|
||||
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_MULTI** = **2** --- Allows selection of multiple items at the same time.
|
||||
- **SELECT_ROW** = **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** = **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.
|
||||
|
||||
----
|
||||
|
||||
@@ -327,31 +352,17 @@ enum **SelectMode**:
|
||||
|
||||
enum **DropModeFlags**:
|
||||
|
||||
- **DROP_MODE_DISABLED** = **0**
|
||||
- **DROP_MODE_DISABLED** = **0** --- Disables all drop sections, but still allows to detect the "on item" drop section by :ref:`get_drop_section_at_position<class_Tree_method_get_drop_section_at_position>`.
|
||||
|
||||
- **DROP_MODE_ON_ITEM** = **1**
|
||||
**Note:** This is the default flag, it has no effect when combined with other flags.
|
||||
|
||||
- **DROP_MODE_INBETWEEN** = **2**
|
||||
- **DROP_MODE_ON_ITEM** = **1** --- Enables the "on item" drop section. This drop section covers the entire item.
|
||||
|
||||
Description
|
||||
-----------
|
||||
When combined with :ref:`DROP_MODE_INBETWEEN<class_Tree_constant_DROP_MODE_INBETWEEN>`, this drop section halves the height and stays centered vertically.
|
||||
|
||||
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.
|
||||
- **DROP_MODE_INBETWEEN** = **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.
|
||||
|
||||
Trees are built via code, using :ref:`TreeItem<class_TreeItem>` objects to create the structure. They have a single root but multiple roots can be simulated if a dummy hidden root is added.
|
||||
|
||||
::
|
||||
|
||||
func _ready():
|
||||
var tree = Tree.new()
|
||||
var root = tree.create_item()
|
||||
tree.set_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")
|
||||
|
||||
To iterate over all the :ref:`TreeItem<class_TreeItem>` objects in a ``Tree`` object, use :ref:`TreeItem.get_next<class_TreeItem_method_get_next>` and :ref:`TreeItem.get_children<class_TreeItem_method_get_children>` after getting the root through :ref:`get_root<class_Tree_method_get_root>`.
|
||||
When combined with :ref:`DROP_MODE_ON_ITEM<class_Tree_constant_DROP_MODE_ON_ITEM>`, these drop sections halves the height and stays on top / bottom accordingly.
|
||||
|
||||
Property Descriptions
|
||||
---------------------
|
||||
@@ -418,6 +429,8 @@ The number of columns.
|
||||
|
||||
The drop mode as an OR combination of flags. See :ref:`DropModeFlags<enum_Tree_DropModeFlags>` constants. Once dropping is done, reverts to :ref:`DROP_MODE_DISABLED<class_Tree_constant_DROP_MODE_DISABLED>`. Setting this during :ref:`Control.can_drop_data<class_Control_method_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.
|
||||
|
||||
----
|
||||
|
||||
.. _class_Tree_property_hide_folding:
|
||||
@@ -489,7 +502,11 @@ Clears the tree. This removes all items.
|
||||
|
||||
- :ref:`TreeItem<class_TreeItem>` **create_item** **(** :ref:`Object<class_Object>` parent=null, :ref:`int<class_int>` idx=-1 **)**
|
||||
|
||||
Create an item in the tree and add it as the last child of ``parent``. If ``parent`` is ``null``, it will be added as the root's last child, or it'll be the the root itself if the tree is empty.
|
||||
Creates an item in the tree and adds it as a child of ``parent``.
|
||||
|
||||
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 ``idx``\ th child of parent, or it will be the last child if there are not enough siblings.
|
||||
|
||||
----
|
||||
|
||||
@@ -497,7 +514,11 @@ Create an item in the tree and add it as the last child of ``parent``. If ``pare
|
||||
|
||||
- void **ensure_cursor_is_visible** **(** **)**
|
||||
|
||||
Makes the currently selected item visible. This will scroll the tree to make sure the selected item is visible.
|
||||
Makes the currently focused cell visible.
|
||||
|
||||
This will scroll the tree if necessary. In :ref:`SELECT_ROW<class_Tree_constant_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 :ref:`SELECT_MULTI<class_Tree_constant_SELECT_MULTI>` mode.
|
||||
|
||||
----
|
||||
|
||||
@@ -505,7 +526,7 @@ Makes the currently selected item visible. This will scroll the tree to make sur
|
||||
|
||||
- :ref:`int<class_int>` **get_column_at_position** **(** :ref:`Vector2<class_Vector2>` position **)** const
|
||||
|
||||
Returns the column index under the given point.
|
||||
Returns the column index at ``position``, or -1 if no item is there.
|
||||
|
||||
----
|
||||
|
||||
@@ -537,9 +558,11 @@ Returns the rectangle for custom popups. Helper to create custom cell controls t
|
||||
|
||||
- :ref:`int<class_int>` **get_drop_section_at_position** **(** :ref:`Vector2<class_Vector2>` position **)** const
|
||||
|
||||
If :ref:`drop_mode_flags<class_Tree_property_drop_mode_flags>` includes :ref:`DROP_MODE_INBETWEEN<class_Tree_constant_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 :ref:`drop_mode_flags<class_Tree_property_drop_mode_flags>` includes :ref:`DROP_MODE_ON_ITEM<class_Tree_constant_DROP_MODE_ON_ITEM>`.
|
||||
Returns the drop section at ``position``, or -100 if no item is there.
|
||||
|
||||
Otherwise, returns 0. If there are no tree items at ``position``, returns -100.
|
||||
Values -1, 0, or 1 will be returned for the "above item", "on item", and "below item" drop sections, respectively. See :ref:`DropModeFlags<enum_Tree_DropModeFlags>` for a description of each drop section.
|
||||
|
||||
To get the item which the returned drop section is relative to, use :ref:`get_item_at_position<class_Tree_method_get_item_at_position>`.
|
||||
|
||||
----
|
||||
|
||||
@@ -563,7 +586,7 @@ Returns the column for the currently edited item. This is only available for cus
|
||||
|
||||
- :ref:`Rect2<class_Rect2>` **get_item_area_rect** **(** :ref:`Object<class_Object>` item, :ref:`int<class_int>` 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.
|
||||
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.
|
||||
|
||||
----
|
||||
|
||||
@@ -579,7 +602,9 @@ Returns the tree item at the specified position (relative to the tree origin pos
|
||||
|
||||
- :ref:`TreeItem<class_TreeItem>` **get_next_selected** **(** :ref:`Object<class_Object>` from **)**
|
||||
|
||||
Returns the next selected item after the given one.
|
||||
Returns the next selected item after the given one, or ``null`` if the end is reached.
|
||||
|
||||
If ``from`` is ``null``, this returns the first selected item.
|
||||
|
||||
----
|
||||
|
||||
@@ -595,7 +620,7 @@ Returns the last pressed button's index.
|
||||
|
||||
- :ref:`TreeItem<class_TreeItem>` **get_root** **(** **)**
|
||||
|
||||
Returns the tree's root item.
|
||||
Returns the tree's root item, or ``null`` if the tree is empty.
|
||||
|
||||
----
|
||||
|
||||
@@ -611,7 +636,11 @@ Returns the current scrolling position.
|
||||
|
||||
- :ref:`TreeItem<class_TreeItem>` **get_selected** **(** **)** const
|
||||
|
||||
Returns the currently selected item.
|
||||
Returns the currently focused item, or ``null`` if no item is focused.
|
||||
|
||||
In :ref:`SELECT_ROW<class_Tree_constant_SELECT_ROW>` and :ref:`SELECT_SINGLE<class_Tree_constant_SELECT_SINGLE>` modes, the focused item is same as the selected item. In :ref:`SELECT_MULTI<class_Tree_constant_SELECT_MULTI>` mode, the focused item is the item under the focus cursor, not necessarily selected.
|
||||
|
||||
To get the currently selected item(s), use :ref:`get_next_selected<class_Tree_method_get_next_selected>`.
|
||||
|
||||
----
|
||||
|
||||
@@ -619,7 +648,11 @@ Returns the currently selected item.
|
||||
|
||||
- :ref:`int<class_int>` **get_selected_column** **(** **)** const
|
||||
|
||||
Returns the current selection's column.
|
||||
Returns the currently focused column, or -1 if no column is focused.
|
||||
|
||||
In :ref:`SELECT_SINGLE<class_Tree_constant_SELECT_SINGLE>` mode, the focused column is the selected column. In :ref:`SELECT_ROW<class_Tree_constant_SELECT_ROW>` mode, the focused column is always 0 if any item is selected. In :ref:`SELECT_MULTI<class_Tree_constant_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 :ref:`TreeItem.is_selected<class_TreeItem_method_is_selected>`.
|
||||
|
||||
----
|
||||
|
||||
|
||||
Reference in New Issue
Block a user