Click or drag to resize

TreeItem Class

Control for a single item inside a Tree. May have child TreeItems and be styled as well as contain buttons.

You can remove a TreeItem by using Free.

Inheritance Hierarchy

Namespace:  Godot
Assembly:  GodotSharp (in GodotSharp.dll) Version: 1.0.0
Syntax
C#
public abstract class TreeItem : Object

The TreeItem type exposes the following members.

Properties
  NameDescription
Public propertyCollapsed

If true, the TreeItem is collapsed.

Public propertyCustomMinimumHeight

The custom minimum height.

Public propertyDisableFolding

If true, folding is disabled for this TreeItem.

Public propertyDynamicObject
Gets a new DynamicGodotObject associated with this instance.
(Inherited from Object.)
Public propertyNativeInstance (Inherited from Object.)
Top
Methods
  NameDescription
Public method_Get

Virtual method which can be overridden to customize the return value of Get(String).

Returns the given property. Returns null if the property does not exist.

(Inherited from Object.)
Public method_GetPropertyList

Virtual method which can be overridden to customize the return value of GetPropertyList.

Returns the object's property list as an Array of dictionaries.

Each property's Dictionary must contain at least name: String and type: int (see VariantType) entries. Optionally, it can also include hint: int (see PropertyHint), hint_string: String, and usage: int (see PropertyUsageFlags).

(Inherited from Object.)
Public method_Notification

Called whenever the object receives a notification, which is identified in what by a constant. The base Object has two constants and , but subclasses such as Node define a lot more notifications which are also received by this method.

(Inherited from Object.)
Public method_Set

Virtual method which can be overridden to customize the return value of Set(String, Object).

Sets a property. Returns true if the property exists.

(Inherited from Object.)
Public methodAddButton

Adds a button with Texturebutton at column column. The button_idx index is used to identify the button when calling other methods. If not specified, the next available index is used, which may be retrieved by calling GetButtonCount(Int32) immediately after this method. Optionally, the button can be disabled and have a tooltip.

Public methodAddUserSignal

Adds a user-defined signal. Arguments are optional, but can be added as an Array of dictionaries, each containing name: String and type: int (see VariantType) entries.

(Inherited from Object.)
Public methodCall

Calls the method on the object and returns the result. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:

call("set", "position", Vector2(42.0, 0.0))

Note: In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase).

(Inherited from Object.)
Public methodCallDeferred

Calls the method on the object during idle time. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:

call_deferred("set", "position", Vector2(42.0, 0.0))

Note: In C#, the method name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined methods where you should use the same convention as in the C# source (typically PascalCase).

(Inherited from Object.)
Public methodCallRecursive

Calls the method on the actual TreeItem and its children recursively. Pass parameters as a comma separated list.

Public methodCallv

Calls the method on the object and returns the result. Contrarily to Call(String, Object), this method does not support a variable number of arguments but expects all parameters to be via a single Array.

callv("set", [ "position", Vector2(42.0, 0.0) ])

(Inherited from Object.)
Public methodCanTranslateMessages

Returns true if the object can translate strings. See SetMessageTranslation(Boolean) and Tr(String).

(Inherited from Object.)
Public methodClearCustomBgColor

Resets the background color for the given column to default.

Public methodClearCustomColor

Resets the color for the given column to default.

Public methodConnect

Connects a signal to a method on a target object. Pass optional binds to the call as an Array of parameters. These parameters will be passed to the method after any parameter used in the call to EmitSignal(String, Object). Use flags to set deferred or one-shot connections. See ObjectConnectFlags constants.

A signal can only be connected once to a method. It will throw an error if already connected, unless the signal was connected with . To avoid this, first, use IsConnected(String, Object, String) to check for existing connections.

If the target is destroyed in the game's lifecycle, the connection will be lost.

Examples:

connect("pressed", self, "_on_Button_pressed") # BaseButton signal
connect("text_entered", self, "_on_LineEdit_text_entered") # LineEdit signal
connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # User-defined signal

An example of the relationship between binds passed to Connect(String, Object, String, Array, UInt32) and parameters used when calling EmitSignal(String, Object):

connect("hit", self, "_on_Player_hit", [ weapon_type, damage ]) # weapon_type and damage are passed last
emit_signal("hit", "Dark lord", 5) # "Dark lord" and 5 are passed first
func _on_Player_hit(hit_by, level, weapon_type, damage):
    print("Hit by %s (lvl %d) with weapon %s for %d damage" % [hit_by, level, weapon_type, damage])

(Inherited from Object.)
Public methodDeselect

Deselects the given column.

Public methodDisconnect

Disconnects a signal from a method on the given target.

If you try to disconnect a connection that does not exist, the method will throw an error. Use IsConnected(String, Object, String) to ensure that the connection exists.

(Inherited from Object.)
Public methodDispose (Inherited from Object.)
Protected methodDispose(Boolean) (Inherited from Object.)
Public methodEmitSignal

Emits the given signal. The signal must exist, so it should be a built-in signal of this class or one of its parent classes, or a user-defined signal. This method supports a variable number of arguments, so parameters are passed as a comma separated list. Example:

emit_signal("hit", weapon_type, damage)
emit_signal("game_over")

(Inherited from Object.)
Public methodEquals (Inherited from Object.)
Public methodEraseButton

Removes the button at index button_idx in column column.

Protected methodFinalize (Inherited from Object.)
Public methodFree

Deletes the object from memory immediately. For Nodes, you may want to use QueueFree to queue the node for safe deletion at the end of the current frame.

Important: If you have a variable pointing to an object, it will not be assigned to null once the object is freed. Instead, it will point to a previously freed instance and you should validate it with @GDScript.is_instance_valid before attempting to call its methods or access its properties.

(Inherited from Object.)
Public methodGet

Returns the Variant value of the given property. If the property doesn't exist, this will return null.

Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

(Inherited from Object.)
Public methodGetButton

Returns the Texture of the button at index button_idx in column column.

Public methodGetButtonCount

Returns the number of buttons in column column. May be used to get the most recently added button's index, if no index was specified.

Public methodGetButtonTooltip

Returns the tooltip string for the button at index button_idx in column column.

Public methodGetCellMode

Returns the column's cell mode.

Public methodGetChildren

Returns the TreeItem's first child item or a null object if there is none.

Public methodGetClass

Returns the object's class as a String.

(Inherited from Object.)
Public methodGetCustomBgColor

Returns the custom background color of column column.

Public methodGetCustomColor

Returns the custom color of column column.

Public methodGetCustomMinimumHeight Obsolete.
Public methodGetExpandRight

Returns true if expand_right is set.

Public methodGetHashCode (Inherited from Object.)
Public methodGetIcon

Returns the given column's icon Texture. Error if no icon is set.

Public methodGetIconMaxWidth

Returns the column's icon's maximum width.

Public methodGetIconModulate

Returns the Color modulating the column's icon.

Public methodGetIconRegion

Returns the icon Texture region as Rect2.

Public methodGetIncomingConnections

Returns an Array of dictionaries with information about signals that are connected to the object.

Each Dictionary contains three String entries:

- source is a reference to the signal emitter.

- signal_name is the name of the connected signal.

- method_name is the name of the method to which the signal is connected.

(Inherited from Object.)
Public methodGetIndexed

Gets the object's property indexed by the given NodePath. The node path should be relative to the current object and can use the colon character (:) to access nested properties. Examples: "position:x" or "material:next_pass:blend_mode".

(Inherited from Object.)
Public methodGetInstanceId

Returns the object's unique instance ID.

This ID can be saved in EncodedObjectAsID, and can be used to retrieve the object instance with @GDScript.instance_from_id.

(Inherited from Object.)
Public methodGetMeta

Returns the object's metadata entry for the given name.

(Inherited from Object.)
Public methodGetMetadata

Returns the metadata value that was set for the given column using SetMetadata(Int32, Object).

Public methodGetMetaList

Returns the object's metadata as a String.

(Inherited from Object.)
Public methodGetMethodList

Returns the object's methods and their signatures as an Array.

(Inherited from Object.)
Public methodGetNext

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

Public methodGetNextVisible

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.

Public methodGetParent

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

Public methodGetPrev

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

Public methodGetPrevVisible

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.

Public methodGetPropertyList

Returns the object's property list as an Array of dictionaries.

Each property's Dictionary contain at least name: String and type: int (see VariantType) entries. Optionally, it can also include hint: int (see PropertyHint), hint_string: String, and usage: int (see PropertyUsageFlags).

(Inherited from Object.)
Public methodGetRange

Returns the value of a column.

Public methodGetRangeConfig

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

Public methodGetScript

Returns the object's Script instance, or null if none is assigned.

(Inherited from Object.)
Public methodGetSignalConnectionList

Returns an Array of connections for the given signal.

(Inherited from Object.)
Public methodGetSignalList

Returns the list of signals as an Array of dictionaries.

(Inherited from Object.)
Public methodGetSuffix

Gets the suffix string shown after the column value.

Public methodGetText

Returns the given column's text.

Public methodGetTextAlign

Returns the given column's text alignment.

Public methodGetTooltip

Returns the given column's tooltip.

Public methodGetType (Inherited from Object.)
Public methodHasMeta

Returns true if a metadata entry is found with the given name.

(Inherited from Object.)
Public methodHasMethod

Returns true if the object contains the given method.

(Inherited from Object.)
Public methodHasSignal

Returns true if the given signal exists.

(Inherited from Object.)
Public methodHasUserSignal

Returns true if the given user-defined signal exists. Only signals added using AddUserSignal(String, Array) are taken into account.

(Inherited from Object.)
Public methodIsBlockingSignals

Returns true if signal emission blocking is enabled.

(Inherited from Object.)
Public methodIsButtonDisabled

Returns true if the button at index button_idx for the given column is disabled.

Public methodIsChecked

Returns true if the given column is checked.

Public methodIsClass

Returns true if the object inherits from the given class.

(Inherited from Object.)
Public methodIsCollapsed Obsolete.
Public methodIsConnected

Returns true if a connection exists for a given signal, target, and method.

(Inherited from Object.)
Public methodIsCustomSetAsButton
Public methodIsEditable

Returns true if column column is editable.

Public methodIsFoldingDisabled Obsolete.
Public methodIsQueuedForDeletion (Inherited from Object.)
Public methodIsSelectable

Returns true if column column is selectable.

Public methodIsSelected

Returns true if column column is selected.

Protected methodMemberwiseClone (Inherited from Object.)
Public methodMoveToBottom

Moves this TreeItem to the bottom in the Tree hierarchy.

Public methodMoveToTop

Moves this TreeItem to the top in the Tree hierarchy.

Public methodNotification

Send a given notification to the object, which will also trigger a call to the _Notification(Int32) method of all classes that the object inherits from.

If reversed is true, _Notification(Int32) is called first on the object's own class, and then up to its successive parent classes. If reversed is false, _Notification(Int32) is called first on the highest ancestor (Object itself), and then down to its successive inheriting classes.

(Inherited from Object.)
Public methodPropertyListChangedNotify

Notify the editor that the property list has changed, so that editor plugins can take the new values into account. Does nothing on export builds.

(Inherited from Object.)
Public methodRemoveChild

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 Free.

Public methodRemoveMeta

Removes a given entry from the object's metadata. See also SetMeta(String, Object).

(Inherited from Object.)
Public methodSelect

Selects the column column.

Public methodSet

Assigns a new value to the given property. If the property does not exist, nothing will happen.

Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

(Inherited from Object.)
Public methodSetBlockSignals

If set to true, signal emission is blocked.

(Inherited from Object.)
Public methodSetButton

Sets the given column's button Texture at index button_idx to button.

Public methodSetButtonDisabled

If true, disables the button at index button_idx in column column.

Public methodSetCellMode
Public methodSetChecked

If true, the column column is checked.

Public methodSetCollapsed Obsolete.
Public methodSetCustomAsButton
Public methodSetCustomBgColor

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

Public methodSetCustomColor

Sets the given column's custom color.

Public methodSetCustomDraw

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.

Public methodSetCustomMinimumHeight Obsolete.
Public methodSetDeferred

Assigns a new value to the given property, after the current frame's physics step. This is equivalent to calling Set(String, Object) via CallDeferred(String, Object), i.e. call_deferred("set", property, value).

Note: In C#, the property name must be specified as snake_case if it is defined by a built-in Godot node. This doesn't apply to user-defined properties where you should use the same convention as in the C# source (typically PascalCase).

(Inherited from Object.)
Public methodSetDisableFolding Obsolete.
Public methodSetEditable

If true, column column is editable.

Public methodSetExpandRight

If true, column column is expanded to the right.

Public methodSetIcon

Sets the given column's icon Texture.

Public methodSetIconMaxWidth

Sets the given column's icon's maximum width.

Public methodSetIconModulate

Modulates the given column's icon with modulate.

Public methodSetIconRegion

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

Public methodSetIndexed

Assigns a new value to the property identified by the NodePath. The node path should be relative to the current object and can use the colon character (:) to access nested properties. Example:

set_indexed("position", Vector2(42, 0))
set_indexed("position:y", -10)
print(position) # (42, -10)

(Inherited from Object.)
Public methodSetMessageTranslation

Defines whether the object can translate strings (with calls to Tr(String)). Enabled by default.

(Inherited from Object.)
Public methodSetMeta

Adds, changes or removes a given entry in the object's metadata. Metadata are serialized and can take any Variant value.

To remove a given entry from the object's metadata, use RemoveMeta(String). Metadata is also removed if its value is set to null. This means you can also use set_meta("name", null) to remove metadata for "name".

(Inherited from Object.)
Public methodSetMetadata

Sets the metadata value for the given column, which can be retrieved later using GetMetadata(Int32). This can be used, for example, to store a reference to the original data.

Public methodSetRange

Sets the value of a column.

Public methodSetRangeConfig

Sets the range of accepted values for a column. The column must be in the mode.

If expr is true, the edit mode slider will use an exponential scale as with ExpEdit.

Public methodSetScript

Assigns a script to the object. Each object can have a single script assigned to it, which are used to extend its functionality.

If the object already had a script, the previous script instance will be freed and its variables and state will be lost. The new script's method will be called.

(Inherited from Object.)
Public methodSetSelectable

If true, the given column is selectable.

Public methodSetSuffix

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

Public methodSetText

Sets the given column's text value.

Public methodSetTextAlign

Sets the given column's text alignment. See TreeItemTextAlign for possible values.

Public methodSetTooltip

Sets the given column's tooltip text.

Public methodCode exampleToSignal
Returns a new SignalAwaiter awaiter configured to complete when the instance source emits the signal specified by the signal parameter.
(Inherited from Object.)
Public methodToString (Inherited from Object.)
Public methodTr

Translates a message using translation catalogs configured in the Project Settings.

Only works if message translation is enabled (which it is by default), otherwise it returns the message unchanged. See SetMessageTranslation(Boolean).

(Inherited from Object.)
Top
See Also