TreeItem

package
v0.0.0-...-80877a9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package TreeItem provides methods for working with TreeItem object instances.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsTreeItem() Instance
}

type HorizontalAlignment

type HorizontalAlignment int
const (
	/*Horizontal left alignment, usually for text-derived classes.*/
	HorizontalAlignmentLeft HorizontalAlignment = 0
	/*Horizontal center alignment, usually for text-derived classes.*/
	HorizontalAlignmentCenter HorizontalAlignment = 1
	/*Horizontal right alignment, usually for text-derived classes.*/
	HorizontalAlignmentRight HorizontalAlignment = 2
	/*Expand row to fit width, usually for text-derived classes.*/
	HorizontalAlignmentFill HorizontalAlignment = 3
)

type Instance

type Instance [1]gdclass.TreeItem

A single item of a [Tree] control. It can contain other [TreeItem]s 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 [method Tree.create_item] or [method TreeItem.create_child]. To remove a [TreeItem], use [method Object.free]. [b]Note:[/b] The ID values used for buttons are 32-bit, unlike [int] which is always 64-bit. They go from [code]-2147483648[/code] to [code]2147483647[/code].

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AddButton

func (self Instance) AddButton(column int, button [1]gdclass.Texture2D)

Adds a button with [Texture2D] [param button] at column [param column]. The [param id] is used to identify the button in the according [signal 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 [method get_button_count] immediately before this method. Optionally, the button can be [param disabled] and have a [param tooltip_text].

func (Instance) AddChild

func (self Instance) AddChild(child [1]gdclass.TreeItem)

Adds a previously unparented [TreeItem] as a direct child of this one. The [param child] item must not be a part of any [Tree] or parented to any [TreeItem]. See also [method remove_child].

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsTreeItem

func (self Instance) AsTreeItem() Instance

func (Instance) ClearCustomBgColor

func (self Instance) ClearCustomBgColor(column int)

Resets the background color for the given column to default.

func (Instance) ClearCustomColor

func (self Instance) ClearCustomColor(column int)

Resets the color for the given column to default.

func (Instance) Collapsed

func (self Instance) Collapsed() bool

func (Instance) CreateChild

func (self Instance) CreateChild() [1]gdclass.TreeItem

Creates an item and adds it as a child. The new item will be inserted as position [param index] (the default value [code]-1[/code] means the last position), or it will be the last child if [param index] is higher than the child count.

func (Instance) CustomMinimumHeight

func (self Instance) CustomMinimumHeight() int

func (Instance) Deselect

func (self Instance) Deselect(column int)

Deselects the given column.

func (Instance) DisableFolding

func (self Instance) DisableFolding() bool

func (Instance) EraseButton

func (self Instance) EraseButton(column int, button_index int)

Removes the button at index [param button_index] in column [param column].

func (Instance) GetAutowrapMode

func (self Instance) GetAutowrapMode(column int) gdclass.TextServerAutowrapMode

Returns the text autowrap mode in the given [param column]. By default it is [constant TextServer.AUTOWRAP_OFF].

func (Instance) GetButton

func (self Instance) GetButton(column int, button_index int) [1]gdclass.Texture2D

Returns the [Texture2D] of the button at index [param button_index] in column [param column].

func (Instance) GetButtonById

func (self Instance) GetButtonById(column int, id int) int

Returns the button index if there is a button with ID [param id] in column [param column], otherwise returns -1.

func (Instance) GetButtonColor

func (self Instance) GetButtonColor(column int, id int) Color.RGBA

Returns the color of the button with ID [param id] in column [param column]. If the specified button does not exist, returns [constant Color.BLACK].

func (Instance) GetButtonCount

func (self Instance) GetButtonCount(column int) int

Returns the number of buttons in column [param column].

func (Instance) GetButtonId

func (self Instance) GetButtonId(column int, button_index int) int

Returns the ID for the button at index [param button_index] in column [param column].

func (Instance) GetButtonTooltipText

func (self Instance) GetButtonTooltipText(column int, button_index int) string

Returns the tooltip text for the button at index [param button_index] in column [param column].

func (Instance) GetCellMode

func (self Instance) GetCellMode(column int) gdclass.TreeItemTreeCellMode

Returns the column's cell mode.

func (Instance) GetChild

func (self Instance) GetChild(index int) [1]gdclass.TreeItem

Returns a child item by its [param index] (see [method get_child_count]). This method is often used for iterating all children of an item. Negative indices access the children from the last one.

func (Instance) GetChildCount

func (self Instance) GetChildCount() int

Returns the number of child items.

func (Instance) GetChildren

func (self Instance) GetChildren() [][1]gdclass.TreeItem

Returns an array of references to the item's children.

func (Instance) GetCustomBgColor

func (self Instance) GetCustomBgColor(column int) Color.RGBA

Returns the custom background color of column [param column].

func (Instance) GetCustomColor

func (self Instance) GetCustomColor(column int) Color.RGBA

Returns the custom color of column [param column].

func (Instance) GetCustomDrawCallback

func (self Instance) GetCustomDrawCallback(column int) Callable.Function

Returns the custom callback of column [param column].

func (Instance) GetCustomFont

func (self Instance) GetCustomFont(column int) [1]gdclass.Font

Returns custom font used to draw text in the column [param column].

func (Instance) GetCustomFontSize

func (self Instance) GetCustomFontSize(column int) int

Returns custom font size used to draw text in the column [param column].

func (Instance) GetExpandRight

func (self Instance) GetExpandRight(column int) bool

Returns [code]true[/code] if [code]expand_right[/code] is set.

func (Instance) GetFirstChild

func (self Instance) GetFirstChild() [1]gdclass.TreeItem

Returns the TreeItem's first child.

func (Instance) GetIcon

func (self Instance) GetIcon(column int) [1]gdclass.Texture2D

Returns the given column's icon [Texture2D]. Error if no icon is set.

func (Instance) GetIconMaxWidth

func (self Instance) GetIconMaxWidth(column int) int

Returns the maximum allowed width of the icon in the given [param column].

func (Instance) GetIconModulate

func (self Instance) GetIconModulate(column int) Color.RGBA

Returns the [Color] modulating the column's icon.

func (Instance) GetIconRegion

func (self Instance) GetIconRegion(column int) Rect2.PositionSize

Returns the icon [Texture2D] region as [Rect2].

func (Instance) GetIndex

func (self Instance) GetIndex() int

Returns the node's order in the tree. For example, if called on the first child item the position is [code]0[/code].

func (Instance) GetLanguage

func (self Instance) GetLanguage(column int) string

Returns item's text language code.

func (Instance) GetMetadata

func (self Instance) GetMetadata(column int) any

Returns the metadata value that was set for the given column using [method set_metadata].

func (Instance) GetNext

func (self Instance) GetNext() [1]gdclass.TreeItem

Returns the next sibling TreeItem in the tree or a null object if there is none.

func (Instance) GetNextInTree

func (self Instance) GetNextInTree() [1]gdclass.TreeItem

Returns the next TreeItem in the tree (in the context of a depth-first search) or a [code]null[/code] object if there is none. If [param wrap] is enabled, the method will wrap around to the first element in the tree when called on the last element, otherwise it returns [code]null[/code].

func (Instance) GetNextVisible

func (self Instance) GetNextVisible() [1]gdclass.TreeItem

Returns the next visible TreeItem in the tree (in the context of a depth-first search) or a [code]null[/code] object if there is none. If [param 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 [code]null[/code].

func (Instance) GetParent

func (self Instance) GetParent() [1]gdclass.TreeItem

Returns the parent TreeItem or a null object if there is none.

func (Instance) GetPrev

func (self Instance) GetPrev() [1]gdclass.TreeItem

Returns the previous sibling TreeItem in the tree or a null object if there is none.

func (Instance) GetPrevInTree

func (self Instance) GetPrevInTree() [1]gdclass.TreeItem

Returns the previous TreeItem in the tree (in the context of a depth-first search) or a [code]null[/code] object if there is none. If [param wrap] is enabled, the method will wrap around to the last element in the tree when called on the first visible element, otherwise it returns [code]null[/code].

func (Instance) GetPrevVisible

func (self Instance) GetPrevVisible() [1]gdclass.TreeItem

Returns the previous visible sibling TreeItem in the tree (in the context of a depth-first search) or a [code]null[/code] object if there is none. If [param 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 [code]null[/code].

func (Instance) GetRange

func (self Instance) GetRange(column int) Float.X

Returns the value of a [constant CELL_MODE_RANGE] column.

func (Instance) GetRangeConfig

func (self Instance) GetRangeConfig(column int) RangeConfig

Returns a dictionary containing the range parameters for a given column. The keys are "min", "max", "step", and "expr".

func (Instance) GetStructuredTextBidiOverride

func (self Instance) GetStructuredTextBidiOverride(column int) gdclass.TextServerStructuredTextParser

Returns the BiDi algorithm override set for this cell.

func (Instance) GetStructuredTextBidiOverrideOptions

func (self Instance) GetStructuredTextBidiOverrideOptions(column int) []any

Returns the additional BiDi options set for this cell.

func (Instance) GetSuffix

func (self Instance) GetSuffix(column int) string

Gets the suffix string shown after the column value.

func (Instance) GetText

func (self Instance) GetText(column int) string

Returns the given column's text.

func (Instance) GetTextAlignment

func (self Instance) GetTextAlignment(column int) HorizontalAlignment

Returns the given column's text alignment.

func (Instance) GetTextDirection

func (self Instance) GetTextDirection(column int) gdclass.ControlTextDirection

Returns item's text base writing direction.

func (Instance) GetTextOverrunBehavior

func (self Instance) GetTextOverrunBehavior(column int) gdclass.TextServerOverrunBehavior

Returns the clipping behavior when the text exceeds the item's bounding rectangle in the given [param column]. By default it is [constant TextServer.OVERRUN_TRIM_ELLIPSIS].

func (Instance) GetTooltipText

func (self Instance) GetTooltipText(column int) string

Returns the given column's tooltip text.

func (Instance) GetTree

func (self Instance) GetTree() [1]gdclass.Tree

Returns the [Tree] that owns this TreeItem.

func (Instance) IsAnyCollapsed

func (self Instance) IsAnyCollapsed() bool

Returns [code]true[/code] if this [TreeItem], or any of its descendants, is collapsed. If [param only_visible] is [code]true[/code] it ignores non-visible [TreeItem]s.

func (Instance) IsButtonDisabled

func (self Instance) IsButtonDisabled(column int, button_index int) bool

Returns [code]true[/code] if the button at index [param button_index] for the given [param column] is disabled.

func (Instance) IsChecked

func (self Instance) IsChecked(column int) bool

Returns [code]true[/code] if the given [param column] is checked.

func (Instance) IsCustomSetAsButton

func (self Instance) IsCustomSetAsButton(column int) bool

Returns [code]true[/code] if the cell was made into a button with [method set_custom_as_button].

func (Instance) IsEditMultiline

func (self Instance) IsEditMultiline(column int) bool

Returns [code]true[/code] if the given [param column] is multiline editable.

func (Instance) IsEditable

func (self Instance) IsEditable(column int) bool

Returns [code]true[/code] if the given [param column] is editable.

func (Instance) IsIndeterminate

func (self Instance) IsIndeterminate(column int) bool

Returns [code]true[/code] if the given [param column] is indeterminate.

func (Instance) IsSelectable

func (self Instance) IsSelectable(column int) bool

Returns [code]true[/code] if the given [param column] is selectable.

func (Instance) IsSelected

func (self Instance) IsSelected(column int) bool

Returns [code]true[/code] if the given [param column] is selected.

func (Instance) IsVisibleInTree

func (self Instance) IsVisibleInTree() bool

Returns [code]true[/code] if [member visible] is [code]true[/code] and all its ancestors are also visible.

func (Instance) MoveAfter

func (self Instance) MoveAfter(item [1]gdclass.TreeItem)

Moves this TreeItem right after the given [param item]. [b]Note:[/b] You can't move to the root or move the root.

func (Instance) MoveBefore

func (self Instance) MoveBefore(item [1]gdclass.TreeItem)

Moves this TreeItem right before the given [param item]. [b]Note:[/b] You can't move to the root or move the root.

func (Instance) PropagateCheck

func (self Instance) PropagateCheck(column int)

Propagates this item's checked status to its children and parents for the given [param column]. It is possible to process the items affected by this method call by connecting to [signal 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 [param emit_signal] is [code]false[/code], then [signal Tree.check_propagated_to_item] will not be emitted.

func (Instance) RemoveChild

func (self Instance) RemoveChild(child [1]gdclass.TreeItem)

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 (see [method add_child]). To completely remove a [TreeItem] use [method Object.free]. [b]Note:[/b] If you want to move a child from one [Tree] to another, then instead of removing and adding it manually you can use [method move_before] or [method move_after].

func (Instance) Select

func (self Instance) Select(column int)

Selects the given [param column].

func (Instance) SetAutowrapMode

func (self Instance) SetAutowrapMode(column int, autowrap_mode gdclass.TextServerAutowrapMode)

Sets the autowrap mode in the given [param column]. If set to something other than [constant TextServer.AUTOWRAP_OFF], the text gets wrapped inside the cell's bounding rectangle.

func (Instance) SetButton

func (self Instance) SetButton(column int, button_index int, button [1]gdclass.Texture2D)

Sets the given column's button [Texture2D] at index [param button_index] to [param button].

func (Instance) SetButtonColor

func (self Instance) SetButtonColor(column int, button_index int, color Color.RGBA)

Sets the given column's button color at index [param button_index] to [param color].

func (Instance) SetButtonDisabled

func (self Instance) SetButtonDisabled(column int, button_index int, disabled bool)

If [code]true[/code], disables the button at index [param button_index] in the given [param column].

func (Instance) SetButtonTooltipText

func (self Instance) SetButtonTooltipText(column int, button_index int, tooltip string)

Sets the tooltip text for the button at index [param button_index] in the given [param column].

func (Instance) SetCellMode

func (self Instance) SetCellMode(column int, mode gdclass.TreeItemTreeCellMode)

Sets the given column's cell mode to [param mode]. This determines how the cell is displayed and edited. See [enum TreeCellMode] constants for details.

func (Instance) SetChecked

func (self Instance) SetChecked(column int, checked bool)

If [param checked] is [code]true[/code], the given [param column] is checked. Clears column's indeterminate status.

func (Instance) SetCollapsed

func (self Instance) SetCollapsed(value bool)

func (Instance) SetCollapsedRecursive

func (self Instance) SetCollapsedRecursive(enable bool)

Collapses or uncollapses this [TreeItem] and all the descendants of this item.

func (Instance) SetCustomAsButton

func (self Instance) SetCustomAsButton(column int, enable bool)

Makes a cell with [constant CELL_MODE_CUSTOM] display as a non-flat button with a [StyleBox].

func (Instance) SetCustomBgColor

func (self Instance) SetCustomBgColor(column int, color Color.RGBA)

Sets the given column's custom background color and whether to just use it as an outline.

func (Instance) SetCustomColor

func (self Instance) SetCustomColor(column int, color Color.RGBA)

Sets the given column's custom color.

func (Instance) SetCustomDraw

func (self Instance) SetCustomDraw(column int, obj Object.Instance, callback string)

Sets the given column's custom draw callback to the [param callback] method on [param object]. The method named [param callback] should accept two arguments: the [TreeItem] that is drawn and its position and size as a [Rect2].

func (Instance) SetCustomDrawCallback

func (self Instance) SetCustomDrawCallback(column int, callback func(item [1]gdclass.TreeItem, rect Rect2.PositionSize))

Sets the given column's custom draw callback. Use an empty [Callable] ([code skip-lint]Callable()[/code]) to clear the custom callback. The cell has to be in [constant CELL_MODE_CUSTOM] to use this feature. The [param callback] should accept two arguments: the [TreeItem] that is drawn and its position and size as a [Rect2].

func (Instance) SetCustomFont

func (self Instance) SetCustomFont(column int, font [1]gdclass.Font)

Sets custom font used to draw text in the given [param column].

func (Instance) SetCustomFontSize

func (self Instance) SetCustomFontSize(column int, font_size int)

Sets custom font size used to draw text in the given [param column].

func (Instance) SetCustomMinimumHeight

func (self Instance) SetCustomMinimumHeight(value int)

func (Instance) SetDisableFolding

func (self Instance) SetDisableFolding(value bool)

func (Instance) SetEditMultiline

func (self Instance) SetEditMultiline(column int, multiline bool)

If [param multiline] is [code]true[/code], the given [param column] is multiline editable. [b]Note:[/b] This option only affects the type of control ([LineEdit] or [TextEdit]) that appears when editing the column. You can set multiline values with [method set_text] even if the column is not multiline editable.

func (Instance) SetEditable

func (self Instance) SetEditable(column int, enabled bool)

If [param enabled] is [code]true[/code], the given [param column] is editable.

func (Instance) SetExpandRight

func (self Instance) SetExpandRight(column int, enable bool)

If [param enable] is [code]true[/code], the given [param column] is expanded to the right.

func (Instance) SetIcon

func (self Instance) SetIcon(column int, texture [1]gdclass.Texture2D)

Sets the given cell's icon [Texture2D]. The cell has to be in [constant CELL_MODE_ICON] mode.

func (Instance) SetIconMaxWidth

func (self Instance) SetIconMaxWidth(column int, width int)

Sets the maximum allowed width of the icon in the given [param column]. This limit is applied on top of the default size of the icon and on top of [theme_item Tree.icon_max_width]. The height is adjusted according to the icon's ratio.

func (Instance) SetIconModulate

func (self Instance) SetIconModulate(column int, modulate Color.RGBA)

Modulates the given column's icon with [param modulate].

func (Instance) SetIconRegion

func (self Instance) SetIconRegion(column int, region Rect2.PositionSize)

Sets the given column's icon's texture region.

func (Instance) SetIndeterminate

func (self Instance) SetIndeterminate(column int, indeterminate bool)

If [param indeterminate] is [code]true[/code], the given [param column] is marked indeterminate. [b]Note:[/b] If set [code]true[/code] from [code]false[/code], then column is cleared of checked status.

func (Instance) SetLanguage

func (self Instance) SetLanguage(column int, language string)

Sets language code of item's text used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

func (Instance) SetMetadata

func (self Instance) SetMetadata(column int, meta any)

Sets the metadata value for the given column, which can be retrieved later using [method get_metadata]. This can be used, for example, to store a reference to the original data.

func (Instance) SetRange

func (self Instance) SetRange(column int, value Float.X)

Sets the value of a [constant CELL_MODE_RANGE] column.

func (Instance) SetRangeConfig

func (self Instance) SetRangeConfig(column int, min Float.X, max Float.X, step Float.X)

Sets the range of accepted values for a column. The column must be in the [constant CELL_MODE_RANGE] mode. If [param expr] is [code]true[/code], the edit mode slider will use an exponential scale as with [member Range.exp_edit].

func (Instance) SetSelectable

func (self Instance) SetSelectable(column int, selectable bool)

If [param selectable] is [code]true[/code], the given [param column] is selectable.

func (Instance) SetStructuredTextBidiOverride

func (self Instance) SetStructuredTextBidiOverride(column int, parser gdclass.TextServerStructuredTextParser)

Set BiDi algorithm override for the structured text. Has effect for cells that display text.

func (Instance) SetStructuredTextBidiOverrideOptions

func (self Instance) SetStructuredTextBidiOverrideOptions(column int, args []any)

Set additional options for BiDi override. Has effect for cells that display text.

func (Instance) SetSuffix

func (self Instance) SetSuffix(column int, text string)

Sets a string to be shown after a column's value (for example, a unit abbreviation).

func (Instance) SetText

func (self Instance) SetText(column int, text string)

Sets the given column's text value.

func (Instance) SetTextAlignment

func (self Instance) SetTextAlignment(column int, text_alignment HorizontalAlignment)

Sets the given column's text alignment. See [enum HorizontalAlignment] for possible values.

func (Instance) SetTextDirection

func (self Instance) SetTextDirection(column int, direction gdclass.ControlTextDirection)

Sets item's text base writing direction.

func (Instance) SetTextOverrunBehavior

func (self Instance) SetTextOverrunBehavior(column int, overrun_behavior gdclass.TextServerOverrunBehavior)

Sets the clipping behavior when the text exceeds the item's bounding rectangle in the given [param column].

func (Instance) SetTooltipText

func (self Instance) SetTooltipText(column int, tooltip string)

Sets the given column's tooltip text.

func (Instance) SetVisible

func (self Instance) SetVisible(value bool)

func (Instance) UncollapseTree

func (self Instance) UncollapseTree()

Uncollapses all [TreeItem]s necessary to reveal this [TreeItem], i.e. all ancestor [TreeItem]s.

func (*Instance) UnsafePointer

func (self *Instance) UnsafePointer() unsafe.Pointer

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

func (Instance) Visible

func (self Instance) Visible() bool

type RangeConfig

type RangeConfig struct {
	Min  float32 `gd:"min"`
	Max  float32 `gd:"max"`
	Step float32 `gd:"step"`
	Expr string  `gd:"expr"`
}

type TreeCellMode

type TreeCellMode = gdclass.TreeItemTreeCellMode //gd:TreeItem.TreeCellMode
const (
	/*Cell shows a string label. When editable, the text can be edited using a [LineEdit], or a [TextEdit] popup if [method set_edit_multiline] is used.*/
	CellModeString TreeCellMode = 0
	/*Cell shows a checkbox, optionally with text. The checkbox can be pressed, released, or indeterminate (via [method set_indeterminate]). The checkbox can't be clicked unless the cell is editable.*/
	CellModeCheck TreeCellMode = 1
	/*Cell shows a numeric range. When editable, it can be edited using a range slider. Use [method set_range] to set the value and [method set_range_config] to configure the range.
	  This cell can also be used in a text dropdown mode when you assign a text with [method set_text]. Separate options with a comma, e.g. [code]"Option1,Option2,Option3"[/code].*/
	CellModeRange TreeCellMode = 2
	/*Cell shows an icon. It can't be edited nor display text.*/
	CellModeIcon TreeCellMode = 3
	/*Cell shows as a clickable button. It will display an arrow similar to [OptionButton], but doesn't feature a dropdown (for that you can use [constant CELL_MODE_RANGE]). Clicking the button emits the [signal Tree.item_edited] signal. The button is flat by default, you can use [method set_custom_as_button] to display it with a [StyleBox].
	  This mode also supports custom drawing using [method set_custom_draw_callback].*/
	CellModeCustom TreeCellMode = 4
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL