class EditorProperty
package godot
extends Container › Control › CanvasItem › Node › Object
@:nativeGen@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:build(godot.Godot.buildUserClass())@:autoBuild(godot.Godot.buildUserClass())@:libType@:csNative@:native("Godot.EditorProperty")@:autoBuild(godot.Godot.buildUserClass())This control allows property editing for one or multiple properties into godot.EditorInspector
. It is added via godot.EditorInspectorPlugin
.
Constructor
Variables
@:native("Checkable")checkable:Bool
Used by the inspector, set to true
when the property is checkable.
@:native("DrawRed")drawRed:Bool
Used by the inspector, set to true
when the property is drawn with the editor theme's warning color. This is used for editable children's properties.
@:native("Keying")keying:Bool
Used by the inspector, set to true
when the property can add keys for animation.
read onlyonMultiplePropertiesChanged:Signal<(properties:Array<String>, value:Array) ‑> Void>
multiple_properties_changed
signal.
read onlyonPropertyKeyedWithValue:Signal<(property:String, value:Any) ‑> Void>
property_keyed_with_value
signal.
read onlyonResourceSelected:Signal<(path:String, resource:Resource) ‑> Void>
resource_selected
signal.
Methods
@:native("AddFocusable")addFocusable(control:Control):Void
If any of the controls added can gain keyboard focus, add it here. This ensures that focus will be restored if the inspector is refreshed.
@:native("EmitChanged")emitChanged(property:String, value:Dynamic, ?field:String, ?changing:Bool):Void
If one or several properties have changed, this must be called. field
is used in case your editor can modify fields separately (as an example, Vector3.x). The changing
argument avoids the editor requesting this property to be refreshed (leave as false
if unsure).
@:native("GetEditedProperty")getEditedProperty():String
Gets the edited property. If your editor is for a single property (added via godot.EditorInspectorPlugin.parseProperty
), then this will return the property.
@:native("GetTooltipText")getTooltipText():String
Must be implemented to provide a custom tooltip to the property editor.
@:native("SetBottomEditor")setBottomEditor(editor:Control):Void
Puts the editor
control below the property label. The control must be previously added using godot.Node.addChild
.
@:native("UpdateProperty")updateProperty():Void
When this virtual function is called, you must update your editor.
Inherited Variables
Defined by Container
Defined by Control
@:native("AnchorBottom")anchorBottom:Single
Anchors the bottom edge of the node to the origin, the center, or the end of its parent control. It changes how the bottom margin updates when the node moves or changes size. You can use one of the godot.Control_Anchor
constants for convenience.
@:native("AnchorLeft")anchorLeft:Single
Anchors the left edge of the node to the origin, the center or the end of its parent control. It changes how the left margin updates when the node moves or changes size. You can use one of the godot.Control_Anchor
constants for convenience.
@:native("AnchorRight")anchorRight:Single
Anchors the right edge of the node to the origin, the center or the end of its parent control. It changes how the right margin updates when the node moves or changes size. You can use one of the godot.Control_Anchor
constants for convenience.
@:native("AnchorTop")anchorTop:Single
Anchors the top edge of the node to the origin, the center or the end of its parent control. It changes how the top margin updates when the node moves or changes size. You can use one of the godot.Control_Anchor
constants for convenience.
@:native("FocusMode")focusMode:Control_FocusModeEnum
The focus access mode for the control (None, Click or All). Only one Control can be focused at the same time, and it will receive keyboard signals.
@:native("FocusNeighbourBottom")focusNeighbourBottom:NodePath
Tells Godot which node it should give keyboard focus to if the user presses the down arrow on the keyboard or down on a gamepad by default. You can change the key by editing the ui_down
input action. The node must be a godot.Control
. If this property is not set, Godot will give focus to the closest godot.Control
to the bottom of this one.
@:native("FocusNeighbourLeft")focusNeighbourLeft:NodePath
Tells Godot which node it should give keyboard focus to if the user presses the left arrow on the keyboard or left on a gamepad by default. You can change the key by editing the ui_left
input action. The node must be a godot.Control
. If this property is not set, Godot will give focus to the closest godot.Control
to the left of this one.
@:native("FocusNeighbourRight")focusNeighbourRight:NodePath
Tells Godot which node it should give keyboard focus to if the user presses the right arrow on the keyboard or right on a gamepad by default. You can change the key by editing the ui_right
input action. The node must be a godot.Control
. If this property is not set, Godot will give focus to the closest godot.Control
to the bottom of this one.
@:native("FocusNeighbourTop")focusNeighbourTop:NodePath
Tells Godot which node it should give keyboard focus to if the user presses the top arrow on the keyboard or top on a gamepad by default. You can change the key by editing the ui_top
input action. The node must be a godot.Control
. If this property is not set, Godot will give focus to the closest godot.Control
to the bottom of this one.
@:native("FocusNext")focusNext:NodePath
Tells Godot which node it should give keyboard focus to if the user presses Tab on a keyboard by default. You can change the key by editing the ui_focus_next
input action.
If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree.
@:native("FocusPrevious")focusPrevious:NodePath
Tells Godot which node it should give keyboard focus to if the user presses Shift+Tab on a keyboard by default. You can change the key by editing the ui_focus_prev
input action.
If this property is not set, Godot will select a "best guess" based on surrounding nodes in the scene tree.
@:native("GrowHorizontal")growHorizontal:Control_GrowDirection
Controls the direction on the horizontal axis in which the control should grow if its horizontal minimum size is changed to be greater than its current size, as the control always has to be at least the minimum size.
@:native("GrowVertical")growVertical:Control_GrowDirection
Controls the direction on the vertical axis in which the control should grow if its vertical minimum size is changed to be greater than its current size, as the control always has to be at least the minimum size.
@:native("HintTooltip")hintTooltip:String
Changes the tooltip text. The tooltip appears when the user's mouse cursor stays idle over this control for a few moments, provided that the godot.Control.mouseFilter
property is not godot.Control_MouseFilterEnum.ignore
. You can change the time required for the tooltip to appear with gui/timers/tooltip_delay_sec
option in Project Settings.
The tooltip popup will use either a default implementation, or a custom one that you can provide by overriding godot.Control._MakeCustomTooltip
. The default tooltip includes a godot.PopupPanel
and godot.Label
whose theme properties can be customized using godot.Theme
methods with the "TooltipPanel"
and "TooltipLabel"
respectively. For example:
var style_box = StyleBoxFlat.new()
style_box.set_bg_color(Color(1, 1, 0))
style_box.set_border_width_all(2)
# We assume here that the `theme` property has been assigned a custom Theme beforehand.
theme.set_stylebox("panel", "TooltipPanel", style_box)
theme.set_color("font_color", "TooltipLabel", Color(0, 1, 1))
@:native("InputPassOnModalCloseClick")inputPassOnModalCloseClick:Bool
Enables whether input should propagate when you close the control as modal.
If false
, stops event handling at the viewport input event handling. The viewport first hides the modal and after marks the input as handled.
@:native("MarginBottom")marginBottom:Single
Distance between the node's bottom edge and its parent control, based on godot.Control.anchorBottom
.
Margins are often controlled by one or multiple parent godot.Container
nodes, so you should not modify them manually if your node is a direct child of a godot.Container
. Margins update automatically when you move or resize the node.
@:native("MarginLeft")marginLeft:Single
Distance between the node's left edge and its parent control, based on godot.Control.anchorLeft
.
Margins are often controlled by one or multiple parent godot.Container
nodes, so you should not modify them manually if your node is a direct child of a godot.Container
. Margins update automatically when you move or resize the node.
@:native("MarginRight")marginRight:Single
Distance between the node's right edge and its parent control, based on godot.Control.anchorRight
.
Margins are often controlled by one or multiple parent godot.Container
nodes, so you should not modify them manually if your node is a direct child of a godot.Container
. Margins update automatically when you move or resize the node.
@:native("MarginTop")marginTop:Single
Distance between the node's top edge and its parent control, based on godot.Control.anchorTop
.
Margins are often controlled by one or multiple parent godot.Container
nodes, so you should not modify them manually if your node is a direct child of a godot.Container
. Margins update automatically when you move or resize the node.
@:native("MouseDefaultCursorShape")mouseDefaultCursorShape:Control_CursorShape
The default cursor shape for this control. Useful for Godot plugins and applications or games that use the system's mouse cursors.
Note: On Linux, shapes may vary depending on the cursor theme of the system.
@:native("MouseFilter")mouseFilter:Control_MouseFilterEnum
Controls whether the control will be able to receive mouse button input events through godot.Control._GuiInput
and how these events should be handled. Also controls whether the control can receive the mouse_entered
, and mouse_exited
signals. See the constants to learn what each does.
@:native("RectClipContent")rectClipContent:Bool
Enables whether rendering of godot.CanvasItem
based children should be clipped to this control's rectangle. If true
, parts of a child which would be visibly outside of this control's rectangle will not be rendered.
@:native("RectGlobalPosition")rectGlobalPosition:Vector2
The node's global position, relative to the world (usually to the top-left corner of the window).
@:native("RectMinSize")rectMinSize:Vector2
The minimum size of the node's bounding rectangle. If you set it to a value greater than (0, 0), the node's bounding rectangle will always have at least this size, even if its content is smaller. If it's set to (0, 0), the node sizes automatically to fit its content, be it a texture or child nodes.
@:native("RectPivotOffset")rectPivotOffset:Vector2
By default, the node's pivot is its top-left corner. When you change its godot.Control.rectRotation
or godot.Control.rectScale
, it will rotate or scale around this pivot. Set this property to godot.Control.rectSize
/ 2 to pivot around the Control's center.
@:native("RectPosition")rectPosition:Vector2
The node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by godot.Control.rectPivotOffset
.
@:native("RectRotation")rectRotation:Single
The node's rotation around its pivot, in degrees. See godot.Control.rectPivotOffset
to change the pivot's position.
@:native("RectScale")rectScale:Vector2
The node's scale, relative to its godot.Control.rectSize
. Change this property to scale the node around its godot.Control.rectPivotOffset
. The Control's godot.Control.hintTooltip
will also scale according to this value.
Note: This property is mainly intended to be used for animation purposes. Text inside the Control will look pixelated or blurry when the Control is scaled. To support multiple resolutions in your project, use an appropriate viewport stretch mode as described in the [https://docs.godotengine.org/en/3.4/tutorials/rendering/multiple_resolutions.html](documentation) instead of scaling Controls individually.
Note: If the Control node is a child of a godot.Container
node, the scale will be reset to Vector2(1, 1)
when the scene is instanced. To set the Control's scale when it's instanced, wait for one frame using yield(get_tree(), "idle_frame")
then set its godot.Control.rectScale
property.
@:native("RectSize")rectSize:Vector2
The size of the node's bounding rectangle, in pixels. godot.Container
nodes update this property automatically.
@:native("SizeFlagsHorizontal")sizeFlagsHorizontal:Int
Tells the parent godot.Container
nodes how they should resize and place the node on the X axis. Use one of the godot.Control_SizeFlags
constants to change the flags. See the constants to learn what each does.
@:native("SizeFlagsStretchRatio")sizeFlagsStretchRatio:Single
If the node and at least one of its neighbours uses the godot.Control_SizeFlags.expand
size flag, the parent godot.Container
will let it take more or less space depending on this property. If this node has a stretch ratio of 2 and its neighbour a ratio of 1, this node will take two thirds of the available space.
@:native("SizeFlagsVertical")sizeFlagsVertical:Int
Tells the parent godot.Container
nodes how they should resize and place the node on the Y axis. Use one of the godot.Control_SizeFlags
constants to change the flags. See the constants to learn what each does.
@:native("Theme")theme:Theme
Changing this property replaces the current godot.Theme
resource this node and all its godot.Control
children use.
Defined by CanvasItem
@:native("LightMask")lightMask:Int
The rendering layers in which this godot.CanvasItem
responds to godot.Light2D
nodes.
@:native("SelfModulate")selfModulate:Color
The color applied to textures on this godot.CanvasItem
. This is not inherited by children godot.CanvasItem
s.
@:native("UseParentMaterial")useParentMaterial:Bool
If true
, the parent godot.CanvasItem
's godot.CanvasItem.material
property is used as this one's material.
@:native("Visible")visible:Bool
If true
, this godot.CanvasItem
is drawn. The node is only visible if all of its antecedents are visible as well (in other words, godot.CanvasItem.isVisibleInTree
must return true
).
Note: For controls that inherit godot.Popup
, the correct way to make them visible is to call one of the multiple popup*()
functions instead.
Defined by Node
@:native("CustomMultiplayer")customMultiplayer:MultiplayerAPI
The override to the default godot.MultiplayerAPI
. Set to null
to use the default godot.SceneTree
one.
@:native("Filename")filename:String
If a scene is instantiated from a file, its topmost node contains the absolute file path from which it was loaded in godot.Node.filename
(e.g. res://levels/1.tscn
). Otherwise, godot.Node.filename
is set to an empty string.
@:native("Multiplayer")read onlymultiplayer:MultiplayerAPI
The godot.MultiplayerAPI
instance associated with this node. Either the godot.Node.customMultiplayer
, or the default SceneTree one (if inside tree).
@:native("Name")name:String
The name of the node. This name is unique among the siblings (other child nodes from the same parent). When set to an existing name, the node will be automatically renamed.
Note: Auto-generated names might include the @
character, which is reserved for unique names when using godot.Node.addChild
. When setting the name manually, any @
will be removed.
@:native("Owner")owner:Node
The node owner. A node can have any other node as owner (as long as it is a valid parent, grandparent, etc. ascending in the tree). When saving a node (using godot.PackedScene
), all the nodes it owns will be saved with it. This allows for the creation of complex godot.SceneTree
s, with instancing and subinstancing.
Note: If you want a child to be persisted to a godot.PackedScene
, you must set godot.Node.owner
in addition to calling godot.Node.addChild
. This is typically relevant for [https://docs.godotengine.org/en/3.4/tutorials/misc/running_code_in_the_editor.html](tool scripts) and [https://docs.godotengine.org/en/3.4/tutorials/plugins/editor/index.html](editor plugins). If godot.Node.addChild
is called without setting godot.Node.owner
, the newly added godot.Node
will not be visible in the scene tree, though it will be visible in the 2D/3D view.
@:native("PauseMode")pauseMode:Node_PauseModeEnum
Pause mode. How the node will behave if the godot.SceneTree
is paused.
@:native("ProcessPriority")processPriority:Int
The node's priority in the execution order of the enabled processing callbacks (i.e. godot.Node.notificationProcess
, godot.Node.notificationPhysicsProcess
and their internal counterparts). Nodes whose process priority value is lower will have their processing callbacks executed first.
Defined by Object
@:native("DynamicObject")read onlydynamicObject:Dynamic
Gets a new godot.DynamicGodotObject
associated with this instance.
@:native("NativeInstance")read onlynativeInstance:IntPtr
The pointer to the native instance of this godot.Object
.
Inherited Methods
Defined by Container
@:native("FitChildInRect")fitChildInRect(child:Control, rect:Rect2):Void
Fit a child control in a given rect. This is mainly a helper for creating custom container classes.
@:native("QueueSort")queueSort():Void
Queue resort of the contained children. This is called automatically anyway, but can be called upon request.
Defined by Control
@:native("_ClipsInput")_ClipsInput():Bool
Virtual method to be implemented by the user. Returns whether godot.Control._GuiInput
should not be called for children controls outside this control's rectangle. Input will be clipped to the Rect of this godot.Control
. Similar to godot.Control.rectClipContent
, but doesn't affect visibility.
If not overridden, defaults to false
.
@:native("_GetMinimumSize")_GetMinimumSize():Vector2
Virtual method to be implemented by the user. Returns the minimum size for this control. Alternative to godot.Control.rectMinSize
for controlling minimum size via code. The actual minimum size will be the max value of these two (in each axis separately).
If not overridden, defaults to Vector2.ZERO
.
@:native("_GuiInput")_GuiInput(event:InputEvent):Void
Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See godot.Control.acceptEvent
.
Example: clicking a control.
func _gui_input(event):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT and event.pressed:
print("I've been clicked D:")
The event won't trigger if:
-
clicking outside the control (see
godot.Control.hasPoint
); -
control has
godot.Control.mouseFilter
set togodot.Control_MouseFilterEnum.ignore
; -
control is obstructed by another
godot.Control
on top of it, which doesn't havegodot.Control.mouseFilter
set togodot.Control_MouseFilterEnum.ignore
; -
control's parent has
godot.Control.mouseFilter
set togodot.Control_MouseFilterEnum.stop
or has accepted the event; -
it happens outside the parent's rectangle and the parent has either
godot.Control.rectClipContent
orgodot.Control._ClipsInput
enabled.
Note: Event position is relative to the control origin.
@:native("_MakeCustomTooltip")_MakeCustomTooltip(forText:String):Control
Virtual method to be implemented by the user. Returns a godot.Control
node that should be used as a tooltip instead of the default one. The for_text
includes the contents of the godot.Control.hintTooltip
property.
The returned node must be of type godot.Control
or Control-derived. It can have child nodes of any type. It is freed when the tooltip disappears, so make sure you always provide a new instance (if you want to use a pre-existing node from your scene tree, you can duplicate it and pass the duplicated instance). When null
or a non-Control node is returned, the default tooltip will be used instead.
The returned node will be added as child to a godot.PopupPanel
, so you should only provide the contents of that panel. That godot.PopupPanel
can be themed using godot.Theme.setStylebox
for the type "TooltipPanel"
(see godot.Control.hintTooltip
for an example).
Note: The tooltip is shrunk to minimal size. If you want to ensure it's fully visible, you might want to set its godot.Control.rectMinSize
to some non-zero value.
Example of usage with a custom-constructed node:
func _make_custom_tooltip(for_text):
var label = Label.new()
label.text = for_text
return label
Example of usage with a custom scene instance:
func _make_custom_tooltip(for_text):
var tooltip = preload("res://SomeTooltipScene.tscn").instance()
tooltip.get_node("Label").text = for_text
return tooltip
@:native("AcceptEvent")acceptEvent():Void
Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to godot.Node._UnhandledInput
or godot.Node._UnhandledKeyInput
.
@:native("AddColorOverride")addColorOverride(name:String, color:Color):Void
Creates a local override for a theme godot.Color
with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override cannot be removed, but it can be overridden with the corresponding default value.
See also godot.Control.getColor
.
Example of overriding a label's color and resetting it later:
# Given the child Label node "MyLabel", override its font color with a custom value.
$MyLabel.add_color_override("font_color", Color(1, 0.5, 0))
# Reset the font color of the child label.
$MyLabel.add_color_override("font_color", get_color("font_color", "Label"))
@:native("AddConstantOverride")addConstantOverride(name:String, constant:Int):Void
Creates a local override for a theme constant with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override cannot be removed, but it can be overridden with the corresponding default value.
See also godot.Control.getConstant
.
@:native("AddFontOverride")addFontOverride(name:String, font:Font):Void
Creates a local override for a theme godot.Font
with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override can be removed by assigning it a null
value.
See also godot.Control.getFont
.
@:native("AddIconOverride")addIconOverride(name:String, texture:Texture):Void
Creates a local override for a theme icon with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override can be removed by assigning it a null
value.
See also godot.Control.getIcon
.
@:native("AddShaderOverride")addShaderOverride(name:String, shader:Shader):Void
Creates a local override for a theme shader with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override can be removed by assigning it a null
value.
@:native("AddStyleboxOverride")addStyleboxOverride(name:String, stylebox:StyleBox):Void
Creates a local override for a theme godot.StyleBox
with the specified name
. Local overrides always take precedence when fetching theme items for the control. An override can be removed by assigning it a null
value.
See also godot.Control.getStylebox
.
Example of modifying a property in a StyleBox by duplicating it:
# The snippet below assumes the child node MyButton has a StyleBoxFlat assigned.
# Resources are shared across instances, so we need to duplicate it
# to avoid modifying the appearance of all other buttons.
var new_stylebox_normal = $MyButton.get_stylebox("normal").duplicate()
new_stylebox_normal.border_width_top = 3
new_stylebox_normal.border_color = Color(0, 1, 0.5)
$MyButton.add_stylebox_override("normal", new_stylebox_normal)
# Remove the stylebox override.
$MyButton.add_stylebox_override("normal", null)
@:native("CanDropData")canDropData(position:Vector2, data:Dynamic):Bool
Godot calls this method to test if data
from a control's godot.Control.getDragData
can be dropped at position
. position
is local to this control.
This method should only be used to test the data. Process the data in godot.Control.dropData
.
func can_drop_data(position, data):
# Check position if it is relevant to you
# Otherwise, just check data
return typeof(data) == TYPE_DICTIONARY and data.has("expected")
@:native("DropData")dropData(position:Vector2, data:Dynamic):Void
Godot calls this method to pass you the data
from a control's godot.Control.getDragData
result. Godot first calls godot.Control.canDropData
to test if data
is allowed to drop at position
where position
is local to this control.
func can_drop_data(position, data):
return typeof(data) == TYPE_DICTIONARY and data.has("color")
func drop_data(position, data):
color = data["color"]
@:native("FindNextValidFocus")findNextValidFocus():Control
Finds the next (below in the tree) godot.Control
that can receive the focus.
@:native("FindPrevValidFocus")findPrevValidFocus():Control
Finds the previous (above in the tree) godot.Control
that can receive the focus.
@:native("ForceDrag")forceDrag(data:Dynamic, preview:Control):Void
Forces drag and bypasses godot.Control.getDragData
and godot.Control.setDragPreview
by passing data
and preview
. Drag will start even if the mouse is neither over nor pressed on this control.
The methods godot.Control.canDropData
and godot.Control.dropData
must be implemented on controls that want to receive drop data.
@:native("GetAnchor")getAnchor(margin:Margin):Single
Returns the anchor identified by margin
constant from godot.Margin
enum. A getter method for godot.Control.anchorBottom
, godot.Control.anchorLeft
, godot.Control.anchorRight
and godot.Control.anchorTop
.
@:native("GetBegin")getBegin():Vector2
Returns godot.Control.marginLeft
and godot.Control.marginTop
. See also godot.Control.rectPosition
.
@:native("GetColor")getColor(name:String, ?themeType:String):Color
Returns a godot.Color
from the first matching godot.Theme
in the tree if that godot.Theme
has a color item with the specified name
and theme_type
. If theme_type
is omitted the class name of the current control is used as the type. If the type is a class name its parent classes are also checked, in order of inheritance.
For the current control its local overrides are considered first (see godot.Control.addColorOverride
), then its assigned godot.Control.theme
. After the current control, each parent control and its assigned godot.Control.theme
are considered; controls without a godot.Control.theme
assigned are skipped. If no matching godot.Theme
is found in the tree, a custom project godot.Theme
(see ) and the default godot.Theme
are used.
func _ready():
# Get the font color defined for the current Control's class, if it exists.
modulate = get_color("font_color")
# Get the font color defined for the Button class.
modulate = get_color("font_color", "Button")
@:native("GetCombinedMinimumSize")getCombinedMinimumSize():Vector2
Returns combined minimum size from godot.Control.rectMinSize
and godot.Control.getMinimumSize
.
@:native("GetConstant")getConstant(name:String, ?themeType:String):Int
Returns a constant from the first matching godot.Theme
in the tree if that godot.Theme
has a constant item with the specified name
and theme_type
.
See godot.Control.getColor
for details.
@:native("GetCursorShape")getCursorShape(?position:Vector2):Control_CursorShape
Returns the mouse cursor shape the control displays on mouse hover. See godot.Control_CursorShape
.
Parameters:
position | If the parameter is null, then the default value is new Vector2(0, 0) |
---|
@:native("GetDragData")getDragData(position:Vector2):Dynamic
Godot calls this method to get data that can be dragged and dropped onto controls that expect drop data. Returns null
if there is no data to drag. Controls that want to receive drop data should implement godot.Control.canDropData
and godot.Control.dropData
. position
is local to this control. Drag may be forced with godot.Control.forceDrag
.
A preview that will follow the mouse that should represent the data can be set with godot.Control.setDragPreview
. A good time to set the preview is in this method.
func get_drag_data(position):
var mydata = make_data()
set_drag_preview(make_preview(mydata))
return mydata
@:native("GetFocusNeighbour")getFocusNeighbour(margin:Margin):NodePath
Returns the focus neighbour identified by margin
constant from godot.Margin
enum. A getter method for godot.Control.focusNeighbourBottom
, godot.Control.focusNeighbourLeft
, godot.Control.focusNeighbourRight
and godot.Control.focusNeighbourTop
.
@:native("GetFocusOwner")getFocusOwner():Control
Returns the control that has the keyboard focus or null
if none.
@:native("GetFont")getFont(name:String, ?themeType:String):Font
Returns a godot.Font
from the first matching godot.Theme
in the tree if that godot.Theme
has a font item with the specified name
and theme_type
.
See godot.Control.getColor
for details.
@:native("GetGlobalRect")getGlobalRect():Rect2
Returns the position and size of the control relative to the top-left corner of the screen. See godot.Control.rectPosition
and godot.Control.rectSize
.
@:native("GetIcon")getIcon(name:String, ?themeType:String):Texture
Returns an icon from the first matching godot.Theme
in the tree if that godot.Theme
has an icon item with the specified name
and theme_type
.
See godot.Control.getColor
for details.
@:native("GetMargin")getMargin(margin:Margin):Single
Returns the anchor identified by margin
constant from godot.Margin
enum. A getter method for godot.Control.marginBottom
, godot.Control.marginLeft
, godot.Control.marginRight
and godot.Control.marginTop
.
@:native("GetMinimumSize")getMinimumSize():Vector2
Returns the minimum size for this control. See godot.Control.rectMinSize
.
@:native("GetParentAreaSize")getParentAreaSize():Vector2
Returns the width/height occupied in the parent control.
@:native("GetRect")getRect():Rect2
Returns the position and size of the control relative to the top-left corner of the parent Control. See godot.Control.rectPosition
and godot.Control.rectSize
.
@:native("GetStylebox")getStylebox(name:String, ?themeType:String):StyleBox
Returns a godot.StyleBox
from the first matching godot.Theme
in the tree if that godot.Theme
has a stylebox item with the specified name
and theme_type
.
See godot.Control.getColor
for details.
@:native("GetThemeDefaultFont")getThemeDefaultFont():Font
Returns the default font from the first matching godot.Theme
in the tree if that godot.Theme
has a valid godot.Theme.defaultFont
value.
See godot.Control.getColor
for details.
@:native("GetTooltip")getTooltip(?atPosition:Vector2):String
Returns the tooltip, which will appear when the cursor is resting over this control. See godot.Control.hintTooltip
.
Parameters:
atPosition | If the parameter is null, then the default value is new Vector2(0, 0) |
---|
@:native("GrabClickFocus")grabClickFocus():Void
Creates an godot.InputEventMouseButton
that attempts to click the control. If the event is received, the control acquires focus.
func _process(delta):
grab_click_focus() #when clicking another Control node, this node will be clicked instead
@:native("GrabFocus")grabFocus():Void
Steal the focus from another control and become the focused control (see godot.Control.focusMode
).
@:native("HasColor")hasColor(name:String, ?themeType:String):Bool
Returns true
if there is a matching godot.Theme
in the tree that has a color item with the specified name
and theme_type
.
See godot.Control.getColor
for details.
@:native("HasColorOverride")hasColorOverride(name:String):Bool
Returns true
if there is a local override for a theme godot.Color
with the specified name
in this godot.Control
node.
@:native("HasConstant")hasConstant(name:String, ?themeType:String):Bool
Returns true
if there is a matching godot.Theme
in the tree that has a constant item with the specified name
and theme_type
.
See godot.Control.getColor
for details.
@:native("HasConstantOverride")hasConstantOverride(name:String):Bool
Returns true
if there is a local override for a theme constant with the specified name
in this godot.Control
node.
@:native("HasFocus")hasFocus():Bool
Returns true
if this is the current focused control. See godot.Control.focusMode
.
@:native("HasFont")hasFont(name:String, ?themeType:String):Bool
Returns true
if there is a matching godot.Theme
in the tree that has a font item with the specified name
and theme_type
.
See godot.Control.getColor
for details.
@:native("HasFontOverride")hasFontOverride(name:String):Bool
Returns true
if there is a local override for a theme godot.Font
with the specified name
in this godot.Control
node.
@:native("HasIcon")hasIcon(name:String, ?themeType:String):Bool
Returns true
if there is a matching godot.Theme
in the tree that has an icon item with the specified name
and theme_type
.
See godot.Control.getColor
for details.
@:native("HasIconOverride")hasIconOverride(name:String):Bool
Returns true
if there is a local override for a theme icon with the specified name
in this godot.Control
node.
@:native("HasPoint")hasPoint(point:Vector2):Bool
Virtual method to be implemented by the user. Returns whether the given point
is inside this control.
If not overridden, default behavior is checking if the point is within control's Rect.
Note: If you want to check if a point is inside the control, you can use get_rect().has_point(point)
.
@:native("HasShaderOverride")hasShaderOverride(name:String):Bool
Returns true
if there is a local override for a theme shader with the specified name
in this godot.Control
node.
@:native("HasStylebox")hasStylebox(name:String, ?themeType:String):Bool
Returns true
if there is a matching godot.Theme
in the tree that has a stylebox item with the specified name
and theme_type
.
See godot.Control.getColor
for details.
@:native("HasStyleboxOverride")hasStyleboxOverride(name:String):Bool
Returns true
if there is a local override for a theme godot.StyleBox
with the specified name
in this godot.Control
node.
@:native("MinimumSizeChanged")minimumSizeChanged():Void
Invalidates the size cache in this node and in parent nodes up to toplevel. Intended to be used with godot.Control.getMinimumSize
when the return value is changed. Setting godot.Control.rectMinSize
directly calls this method automatically.
@:native("ReleaseFocus")releaseFocus():Void
Give up the focus. No other control will be able to receive keyboard input.
@:native("SetAnchor")setAnchor(margin:Margin, anchor:Single, ?keepMargin:Bool, ?pushOppositeAnchor:Bool):Void
Sets the anchor identified by margin
constant from godot.Margin
enum to value anchor
. A setter method for godot.Control.anchorBottom
, godot.Control.anchorLeft
, godot.Control.anchorRight
and godot.Control.anchorTop
.
If keep_margin
is true
, margins aren't updated after this operation.
If push_opposite_anchor
is true
and the opposite anchor overlaps this anchor, the opposite one will have its value overridden. For example, when setting left anchor to 1 and the right anchor has value of 0.5, the right anchor will also get value of 1. If push_opposite_anchor
was false
, the left anchor would get value 0.5.
@:native("SetAnchorAndMargin")setAnchorAndMargin(margin:Margin, anchor:Single, offset:Single, ?pushOppositeAnchor:Bool):Void
Works the same as godot.Control.setAnchor
, but instead of keep_margin
argument and automatic update of margin, it allows to set the margin offset yourself (see godot.Control.setMargin
).
@:native("SetAnchorsAndMarginsPreset")setAnchorsAndMarginsPreset(preset:Control_LayoutPreset, ?resizeMode:Control_LayoutPresetMode, ?margin:Int):Void
Sets both anchor preset and margin preset. See godot.Control.setAnchorsPreset
and godot.Control.setMarginsPreset
.
@:native("SetAnchorsPreset")setAnchorsPreset(preset:Control_LayoutPreset, ?keepMargins:Bool):Void
Sets the anchors to a preset
from godot.Control_LayoutPreset
enum. This is the code equivalent to using the Layout menu in the 2D editor.
If keep_margins
is true
, control's position will also be updated.
@:native("SetBegin")setBegin(position:Vector2):Void
Sets godot.Control.marginLeft
and godot.Control.marginTop
at the same time. Equivalent of changing godot.Control.rectPosition
.
@:native("SetDragForwarding")setDragForwarding(target:Control):Void
Forwards the handling of this control's drag and drop to target
control.
Forwarding can be implemented in the target control similar to the methods godot.Control.getDragData
, godot.Control.canDropData
, and godot.Control.dropData
but with two differences:
-
The function name must be suffixed with _fw
-
The function must take an extra argument that is the control doing the forwarding
# ThisControl.gd
extends Control
func _ready():
set_drag_forwarding(target_control)
# TargetControl.gd
extends Control
func can_drop_data_fw(position, data, from_control):
return true
func drop_data_fw(position, data, from_control):
my_handle_data(data)
func get_drag_data_fw(position, from_control):
set_drag_preview(my_preview)
return my_data()
@:native("SetDragPreview")setDragPreview(control:Control):Void
Shows the given control at the mouse pointer. A good time to call this method is in godot.Control.getDragData
. The control must not be in the scene tree. You should not free the control, and you should not keep a reference to the control beyond the duration of the drag. It will be deleted automatically after the drag has ended.
export (Color, RGBA) var color = Color(1, 0, 0, 1)
func get_drag_data(position):
# Use a control that is not in the tree
var cpb = ColorPickerButton.new()
cpb.color = color
cpb.rect_size = Vector2(50, 50)
set_drag_preview(cpb)
return color
@:native("SetEnd")setEnd(position:Vector2):Void
Sets godot.Control.marginRight
and godot.Control.marginBottom
at the same time.
@:native("SetFocusNeighbour")setFocusNeighbour(margin:Margin, neighbour:NodePath):Void
Sets the anchor identified by margin
constant from godot.Margin
enum to godot.Control
at neighbor
node path. A setter method for godot.Control.focusNeighbourBottom
, godot.Control.focusNeighbourLeft
, godot.Control.focusNeighbourRight
and godot.Control.focusNeighbourTop
.
@:native("SetGlobalPosition")setGlobalPosition(position:Vector2, ?keepMargins:Bool):Void
Sets the godot.Control.rectGlobalPosition
to given position
.
If keep_margins
is true
, control's anchors will be updated instead of margins.
@:native("SetMargin")setMargin(margin:Margin, offset:Single):Void
Sets the margin identified by margin
constant from godot.Margin
enum to given offset
. A setter method for godot.Control.marginBottom
, godot.Control.marginLeft
, godot.Control.marginRight
and godot.Control.marginTop
.
@:native("SetMarginsPreset")setMarginsPreset(preset:Control_LayoutPreset, ?resizeMode:Control_LayoutPresetMode, ?margin:Int):Void
Sets the margins to a preset
from godot.Control_LayoutPreset
enum. This is the code equivalent to using the Layout menu in the 2D editor.
Use parameter resize_mode
with constants from godot.Control_LayoutPresetMode
to better determine the resulting size of the godot.Control
. Constant size will be ignored if used with presets that change size, e.g. PRESET_LEFT_WIDE
.
Use parameter margin
to determine the gap between the godot.Control
and the edges.
@:native("SetPosition")setPosition(position:Vector2, ?keepMargins:Bool):Void
Sets the godot.Control.rectPosition
to given position
.
If keep_margins
is true
, control's anchors will be updated instead of margins.
@:native("SetSize")setSize(size:Vector2, ?keepMargins:Bool):Void
Sets the size (see godot.Control.rectSize
).
If keep_margins
is true
, control's anchors will be updated instead of margins.
@:native("ShowModal")showModal(?exclusive:Bool):Void
Displays a control as modal. Control must be a subwindow. Modal controls capture the input signals until closed or the area outside them is accessed. When a modal control loses focus, or the ESC key is pressed, they automatically hide. Modal controls are used extensively for popup dialogs and menus.
If exclusive
is true
, other controls will not receive input and clicking outside this control will not close it.
@:native("WarpMouse")warpMouse(toPosition:Vector2):Void
Moves the mouse cursor to to_position
, relative to godot.Control.rectPosition
of this godot.Control
.
Defined by CanvasItem
@:native("_Draw")_Draw():Void
Overridable function called by the engine (if defined) to draw the canvas item.
@:native("DrawArc")drawArc(center:Vector2, radius:Single, startAngle:Single, endAngle:Single, pointCount:Int, color:Color, ?width:Single, ?antialiased:Bool):Void
Draws a unfilled arc between the given angles. The larger the value of point_count
, the smoother the curve. See also godot.CanvasItem.drawCircle
.
Note: Line drawing is not accelerated by batching if antialiased
is true
.
Note: Due to how it works, built-in antialiasing will not look correct for translucent lines and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedRegularPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
@:native("DrawChar")drawChar(font:Font, position:Vector2, char:String, next:String, ?modulate:Color):Single
Draws a string character using a custom font. Returns the advance, depending on the character width and kerning with an optional next character.
Parameters:
modulate | If the parameter is null, then the default value is new Color(1, 1, 1, 1) |
---|
@:native("DrawCircle")drawCircle(position:Vector2, radius:Single, color:Color):Void
Draws a colored, filled circle. See also godot.CanvasItem.drawArc
, godot.CanvasItem.drawPolyline
and godot.CanvasItem.drawPolygon
.
Note: Built-in antialiasing is not provided for godot.CanvasItem.drawCircle
. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedRegularPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
@:native("DrawColoredPolygon")drawColoredPolygon(points:Array<Vector2>, color:Color, ?uvs:Array<Vector2>, ?texture:Texture, ?normalMap:Texture, ?antialiased:Bool):Void
Draws a colored polygon of any amount of points, convex or concave. Unlike godot.CanvasItem.drawPolygon
, a single color must be specified for the whole polygon.
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
Parameters:
uvs | If the parameter is null, then the default value is Array.Empty<Vector2>() |
---|
@:native("DrawLine")drawLine(from:Vector2, to:Vector2, color:Color, ?width:Single, ?antialiased:Bool):Void
Draws a line from a 2D point to another, with a given color and width. It can be optionally antialiased. See also godot.CanvasItem.drawMultiline
and godot.CanvasItem.drawPolyline
.
Note: Line drawing is not accelerated by batching if antialiased
is true
.
Note: Due to how it works, built-in antialiasing will not look correct for translucent lines and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
@:native("DrawMesh")drawMesh(mesh:Mesh, texture:Texture, ?normalMap:Texture, ?transform:Transform2D, ?modulate:Color):Void
Draws a godot.Mesh
in 2D, using the provided texture. See godot.MeshInstance2D
for related documentation.
Parameters:
transform | If the parameter is null, then the default value is Transform2D.Identity |
---|---|
modulate | If the parameter is null, then the default value is new Color(1, 1, 1, 1) |
@:native("DrawMultiline")drawMultiline(points:Array<Vector2>, color:Color, ?width:Single, ?antialiased:Bool):Void
Draws multiple disconnected lines with a uniform color
. When drawing large amounts of lines, this is faster than using individual godot.CanvasItem.drawLine
calls. To draw interconnected lines, use godot.CanvasItem.drawPolyline
instead.
Note: width
and antialiased
are currently not implemented and have no effect. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
@:native("DrawMultilineColors")drawMultilineColors(points:Array<Vector2>, colors:Array<Color>, ?width:Single, ?antialiased:Bool):Void
Draws multiple disconnected lines with a uniform width
and segment-by-segment coloring. Colors assigned to line segments match by index between points
and colors
. When drawing large amounts of lines, this is faster than using individual godot.CanvasItem.drawLine
calls. To draw interconnected lines, use godot.CanvasItem.drawPolylineColors
instead.
Note: width
and antialiased
are currently not implemented and have no effect. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedLine2D node. That node relies on a texture with custom mipmaps to perform antialiasing. 2D batching is also still supported with those antialiased lines.
@:native("DrawMultimesh")drawMultimesh(multimesh:MultiMesh, texture:Texture, ?normalMap:Texture):Void
Draws a godot.MultiMesh
in 2D with the provided texture. See godot.MultiMeshInstance2D
for related documentation.
@:native("DrawPolygon")drawPolygon(points:Array<Vector2>, colors:Array<Color>, ?uvs:Array<Vector2>, ?texture:Texture, ?normalMap:Texture, ?antialiased:Bool):Void
Draws a solid polygon of any amount of points, convex or concave. Unlike godot.CanvasItem.drawColoredPolygon
, each point's color can be changed individually. See also godot.CanvasItem.drawPolyline
and godot.CanvasItem.drawPolylineColors
.
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
Parameters:
uvs | If the parameter is null, then the default value is Array.Empty<Vector2>() |
---|
@:native("DrawPolyline")drawPolyline(points:Array<Vector2>, color:Color, ?width:Single, ?antialiased:Bool):Void
Draws interconnected line segments with a uniform color
and width
and optional antialiasing. When drawing large amounts of lines, this is faster than using individual godot.CanvasItem.drawLine
calls. To draw disconnected lines, use godot.CanvasItem.drawMultiline
instead. See also godot.CanvasItem.drawPolygon
.
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
@:native("DrawPolylineColors")drawPolylineColors(points:Array<Vector2>, colors:Array<Color>, ?width:Single, ?antialiased:Bool):Void
Draws interconnected line segments with a uniform width
and segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between points
and colors
. When drawing large amounts of lines, this is faster than using individual godot.CanvasItem.drawLine
calls. To draw disconnected lines, use godot.CanvasItem.drawMultilineColors
instead. See also godot.CanvasItem.drawPolygon
.
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
@:native("DrawPrimitive")drawPrimitive(points:Array<Vector2>, colors:Array<Color>, uvs:Array<Vector2>, ?texture:Texture, ?width:Single, ?normalMap:Texture):Void
Draws a custom primitive. 1 point for a point, 2 points for a line, 3 points for a triangle, and 4 points for a quad. If 0 points or more than 4 points are specified, nothing will be drawn and an error message will be printed. See also godot.CanvasItem.drawLine
, godot.CanvasItem.drawPolyline
, godot.CanvasItem.drawPolygon
, and godot.CanvasItem.drawRect
.
@:native("DrawRect")drawRect(rect:Rect2, color:Color, ?filled:Bool, ?width:Single, ?antialiased:Bool):Void
Draws a rectangle. If filled
is true
, the rectangle will be filled with the color
specified. If filled
is false
, the rectangle will be drawn as a stroke with the color
and width
specified. If antialiased
is true
, the lines will attempt to perform antialiasing using OpenGL line smoothing.
Note: width
and antialiased
are only effective if filled
is false
.
Note: Due to how it works, built-in antialiasing will not look correct for translucent polygons and may not work on certain platforms. As a workaround, install the [https://github.com/godot-extended-libraries/godot-antialiased-line2d](Antialiased Line2D) add-on then create an AntialiasedPolygon2D node. That node relies on a texture with custom mipmaps to perform antialiasing.
@:native("DrawSetTransform")drawSetTransform(position:Vector2, rotation:Single, scale:Vector2):Void
Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this.
@:native("DrawSetTransformMatrix")drawSetTransformMatrix(xform:Transform2D):Void
Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this.
@:native("DrawString")drawString(font:Font, position:Vector2, text:String, ?modulate:Color, ?clipW:Int):Void
Draws text
using the specified font
at the position
(bottom-left corner using the baseline of the font). The text will have its color multiplied by modulate
. If clip_w
is greater than or equal to 0, the text will be clipped if it exceeds the specified width.
Example using the default project font:
# If using this method in a script that redraws constantly, move the
# `default_font` declaration to a member variable assigned in `_ready()`
# so the Control is only created once.
var default_font = Control.new().get_font("font")
draw_string(default_font, Vector2(64, 64), "Hello world")
See also godot.Font.draw
.
Parameters:
modulate | If the parameter is null, then the default value is new Color(1, 1, 1, 1) |
---|
@:native("DrawTexture")drawTexture(texture:Texture, position:Vector2, ?modulate:Color, ?normalMap:Texture):Void
Draws a texture at a given position.
Parameters:
modulate | If the parameter is null, then the default value is new Color(1, 1, 1, 1) |
---|
@:native("DrawTextureRect")drawTextureRect(texture:Texture, rect:Rect2, tile:Bool, ?modulate:Color, ?transpose:Bool, ?normalMap:Texture):Void
Draws a textured rectangle at a given position, optionally modulated by a color. If transpose
is true
, the texture will have its X and Y coordinates swapped.
Parameters:
modulate | If the parameter is null, then the default value is new Color(1, 1, 1, 1) |
---|
@:native("DrawTextureRectRegion")drawTextureRectRegion(texture:Texture, rect:Rect2, srcRect:Rect2, ?modulate:Color, ?transpose:Bool, ?normalMap:Texture, ?clipUv:Bool):Void
Draws a textured rectangle region at a given position, optionally modulated by a color. If transpose
is true
, the texture will have its X and Y coordinates swapped.
Parameters:
modulate | If the parameter is null, then the default value is new Color(1, 1, 1, 1) |
---|
@:native("ForceUpdateTransform")forceUpdateTransform():Void
Forces the transform to update. Transform changes in physics are not instant for performance reasons. Transforms are accumulated and then set. Use this if you need an up-to-date transform when doing physics operations.
@:native("GetCanvas")getCanvas():RID
Returns the godot.RID
of the godot.World2D
canvas where this item is in.
@:native("GetCanvasItem")getCanvasItem():RID
Returns the canvas item RID used by godot.VisualServer
for this item.
@:native("GetCanvasTransform")getCanvasTransform():Transform2D
Returns the transform matrix of this item's canvas.
@:native("GetGlobalMousePosition")getGlobalMousePosition():Vector2
Returns the global position of the mouse.
@:native("GetGlobalTransform")getGlobalTransform():Transform2D
Returns the global transform matrix of this item.
@:native("GetGlobalTransformWithCanvas")getGlobalTransformWithCanvas():Transform2D
Returns the global transform matrix of this item in relation to the canvas.
@:native("GetLocalMousePosition")getLocalMousePosition():Vector2
Returns the mouse position relative to this item's position.
@:native("GetViewportRect")getViewportRect():Rect2
Returns the viewport's boundaries as a godot.Rect2
.
@:native("GetViewportTransform")getViewportTransform():Transform2D
Returns this item's transform in relation to the viewport.
@:native("Hide")hide():Void
Hide the godot.CanvasItem
if it's currently visible. This is equivalent to setting godot.CanvasItem.visible
to false
.
@:native("IsLocalTransformNotificationEnabled")isLocalTransformNotificationEnabled():Bool
Returns true
if local transform notifications are communicated to children.
@:native("IsSetAsToplevel")isSetAsToplevel():Bool
Returns true
if the node is set as top-level. See godot.CanvasItem.setAsToplevel
.
@:native("IsTransformNotificationEnabled")isTransformNotificationEnabled():Bool
Returns true
if global transform notifications are communicated to children.
@:native("IsVisibleInTree")isVisibleInTree():Bool
Returns true
if the node is present in the godot.SceneTree
, its godot.CanvasItem.visible
property is true
and all its antecedents are also visible. If any antecedent is hidden, this node will not be visible in the scene tree.
@:native("MakeCanvasPositionLocal")makeCanvasPositionLocal(screenPoint:Vector2):Vector2
Assigns screen_point
as this node's new local transform.
@:native("MakeInputLocal")makeInputLocal(event:InputEvent):InputEvent
Transformations issued by event
's inputs are applied in local space instead of global space.
@:native("SetAsToplevel")setAsToplevel(enable:Bool):Void
If enable
is true
, this godot.CanvasItem
will not inherit its transform from parent godot.CanvasItem
s. Its draw order will also be changed to make it draw on top of other godot.CanvasItem
s that are not set as top-level. The godot.CanvasItem
will effectively act as if it was placed as a child of a bare godot.Node
. See also godot.CanvasItem.isSetAsToplevel
.
@:native("SetNotifyLocalTransform")setNotifyLocalTransform(enable:Bool):Void
If enable
is true
, children will be updated with local transform data.
@:native("SetNotifyTransform")setNotifyTransform(enable:Bool):Void
If enable
is true
, children will be updated with global transform data.
@:native("Show")show():Void
Show the godot.CanvasItem
if it's currently hidden. This is equivalent to setting godot.CanvasItem.visible
to true
. For controls that inherit godot.Popup
, the correct way to make them visible is to call one of the multiple popup*()
functions instead.
@:native("Update")update():Void
Queue the godot.CanvasItem
for update. godot.CanvasItem.notificationDraw
will be called on idle time to request redraw.
Defined by Node
@:native("_EnterTree")_EnterTree():Void
Called when the node enters the godot.SceneTree
(e.g. upon instancing, scene changing, or after calling godot.Node.addChild
in a script). If the node has children, its godot.Node._EnterTree
callback will be called first, and then that of the children.
Corresponds to the godot.Node.notificationEnterTree
notification in godot.Object._Notification
.
@:native("_ExitTree")_ExitTree():Void
Called when the node is about to leave the godot.SceneTree
(e.g. upon freeing, scene changing, or after calling godot.Node.removeChild
in a script). If the node has children, its godot.Node._ExitTree
callback will be called last, after all its children have left the tree.
Corresponds to the godot.Node.notificationExitTree
notification in godot.Object._Notification
and signal tree_exiting
. To get notified when the node has already left the active tree, connect to the tree_exited
.
@:native("_GetConfigurationWarning")_GetConfigurationWarning():String
The string returned from this method is displayed as a warning in the Scene Dock if the script that overrides it is a tool
script.
Returning an empty string produces no warning.
Call godot.Node.updateConfigurationWarning
when the warning needs to be updated for this node.
@:native("_Input")_Input(event:InputEvent):Void
Called when there is an input event. The input event propagates up through the node tree until a node consumes it.
It is only called if input processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcessInput
.
To consume the input event and stop it propagating further to other nodes, godot.SceneTree.setInputAsHandled
can be called.
For gameplay input, godot.Node._UnhandledInput
and godot.Node._UnhandledKeyInput
are usually a better fit as they allow the GUI to intercept the events first.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
@:native("_PhysicsProcess")_PhysicsProcess(delta:Single):Void
Called during the physics processing step of the main loop. Physics processing means that the frame rate is synced to the physics, i.e. the delta
variable should be constant. delta
is in seconds.
It is only called if physics processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setPhysicsProcess
.
Corresponds to the godot.Node.notificationPhysicsProcess
notification in godot.Object._Notification
.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
@:native("_Process")_Process(delta:Single):Void
Called during the processing step of the main loop. Processing happens at every frame and as fast as possible, so the delta
time since the previous frame is not constant. delta
is in seconds.
It is only called if processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcess
.
Corresponds to the godot.Node.notificationProcess
notification in godot.Object._Notification
.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
@:native("_Ready")_Ready():Void
Called when the node is "ready", i.e. when both the node and its children have entered the scene tree. If the node has children, their godot.Node._Ready
callbacks get triggered first, and the parent node will receive the ready notification afterwards.
Corresponds to the godot.Node.notificationReady
notification in godot.Object._Notification
. See also the onready
keyword for variables.
Usually used for initialization. For even earlier initialization, may be used. See also godot.Node._EnterTree
.
Note: godot.Node._Ready
may be called only once for each node. After removing a node from the scene tree and adding again, _ready
will not be called for the second time. This can be bypassed with requesting another call with godot.Node.requestReady
, which may be called anywhere before adding the node again.
@:native("_UnhandledInput")_UnhandledInput(event:InputEvent):Void
Called when an godot.InputEvent
hasn't been consumed by godot.Node._Input
or any GUI. The input event propagates up through the node tree until a node consumes it.
It is only called if unhandled input processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcessUnhandledInput
.
To consume the input event and stop it propagating further to other nodes, godot.SceneTree.setInputAsHandled
can be called.
For gameplay input, this and godot.Node._UnhandledKeyInput
are usually a better fit than godot.Node._Input
as they allow the GUI to intercept the events first.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
@:native("_UnhandledKeyInput")_UnhandledKeyInput(event:InputEventKey):Void
Called when an godot.InputEventKey
hasn't been consumed by godot.Node._Input
or any GUI. The input event propagates up through the node tree until a node consumes it.
It is only called if unhandled key input processing is enabled, which is done automatically if this method is overridden, and can be toggled with godot.Node.setProcessUnhandledKeyInput
.
To consume the input event and stop it propagating further to other nodes, godot.SceneTree.setInputAsHandled
can be called.
For gameplay input, this and godot.Node._UnhandledInput
are usually a better fit than godot.Node._Input
as they allow the GUI to intercept the events first.
Note: This method is only called if the node is present in the scene tree (i.e. if it's not orphan).
@:native("AddChild")addChild(node:Node, ?legibleUniqueName:Bool):Void
Adds a child node. Nodes can have any number of children, but every child must have a unique name. Child nodes are automatically deleted when the parent node is deleted, so an entire scene can be removed by deleting its topmost node.
If legible_unique_name
is true
, the child node will have a human-readable name based on the name of the node being instanced instead of its type.
Note: If the child node already has a parent, the function will fail. Use godot.Node.removeChild
first to remove the node from its current parent. For example:
if child_node.get_parent():
child_node.get_parent().remove_child(child_node)
add_child(child_node)
Note: If you want a child to be persisted to a godot.PackedScene
, you must set godot.Node.owner
in addition to calling godot.Node.addChild
. This is typically relevant for [https://docs.godotengine.org/en/3.4/tutorials/misc/running_code_in_the_editor.html](tool scripts) and [https://docs.godotengine.org/en/3.4/tutorials/plugins/editor/index.html](editor plugins). If godot.Node.addChild
is called without setting godot.Node.owner
, the newly added godot.Node
will not be visible in the scene tree, though it will be visible in the 2D/3D view.
@:native("AddChildBelowNode")addChildBelowNode(node:Node, childNode:Node, ?legibleUniqueName:Bool):Void
Adds child_node
as a child. The child is placed below the given node
in the list of children.
If legible_unique_name
is true
, the child node will have a human-readable name based on the name of the node being instanced instead of its type.
@:native("AddToGroup")addToGroup(group:String, ?persistent:Bool):Void
Adds the node to a group. Groups are helpers to name and organize a subset of nodes, for example "enemies" or "collectables". A node can be in any number of groups. Nodes can be assigned a group at any time, but will not be added until they are inside the scene tree (see godot.Node.isInsideTree
). See notes in the description, and the group methods in godot.SceneTree
.
The persistent
option is used when packing node to godot.PackedScene
and saving to file. Non-persistent groups aren't stored.
Note: For performance reasons, the order of node groups is not guaranteed. The order of node groups should not be relied upon as it can vary across project runs.
@:native("CanProcess")canProcess():Bool
Returns true
if the node can process while the scene tree is paused (see godot.Node.pauseMode
). Always returns true
if the scene tree is not paused, and false
if the node is not in the tree.
@:native("Duplicate")duplicate(?flags:Int):Node
Duplicates the node, returning a new node.
You can fine-tune the behavior using the flags
(see godot.Node_DuplicateFlags
).
Note: It will not work properly if the node contains a script with constructor arguments (i.e. needs to supply arguments to method). In that case, the node will be duplicated without a script.
@:native("FindNode")findNode(mask:String, ?recursive:Bool, ?owned:Bool):Node
Finds a descendant of this node whose name matches mask
as in String.match
(i.e. case-sensitive, but "*"
matches zero or more characters and "?"
matches any single character except "."
). Returns null
if no matching godot.Node
is found.
Note: It does not match against the full path, just against individual node names.
If owned
is true
, this method only finds nodes whose owner is this node. This is especially important for scenes instantiated through a script, because those scenes don't have an owner.
Note: As this method walks through all the descendants of the node, it is the slowest way to get a reference to another node. Whenever possible, consider using godot.Node.getNode
instead. To avoid using godot.Node.findNode
too often, consider caching the node reference into a variable.
@:native("FindParent")findParent(mask:String):Node
Finds the first parent of the current node whose name matches mask
as in String.match
(i.e. case-sensitive, but "*"
matches zero or more characters and "?"
matches any single character except "."
).
Note: It does not match against the full path, just against individual node names.
Note: As this method walks upwards in the scene tree, it can be slow in large, deeply nested scene trees. Whenever possible, consider using godot.Node.getNode
instead. To avoid using godot.Node.findParent
too often, consider caching the node reference into a variable.
@:native("GetChild")getChild(idx:Int):Node
Returns a child node by its index (see godot.Node.getChildCount
). This method is often used for iterating all children of a node.
To access a child node via its name, use godot.Node.getNode
.
@:native("GetGroups")getGroups():Array
Returns an array listing the groups that the node is a member of.
Note: For performance reasons, the order of node groups is not guaranteed. The order of node groups should not be relied upon as it can vary across project runs.
Note: The engine uses some group names internally (all starting with an underscore). To avoid conflicts with internal groups, do not add custom groups whose name starts with an underscore. To exclude internal groups while looping over godot.Node.getGroups
, use the following snippet:
# Stores the node's non-internal groups only (as an array of Strings).
var non_internal_groups = []
for group in get_groups():
if not group.begins_with("_"):
non_internal_groups.push_back(group)
@:native("GetIndex")getIndex():Int
Returns the node's index, i.e. its position among the siblings of its parent.
@:native("GetNetworkMaster")getNetworkMaster():Int
Returns the peer ID of the network master for this node. See godot.Node.setNetworkMaster
.
@:native("GetNode")getNode(path:NodePath):Node
Fetches a node. The godot.NodePath
can be either a relative path (from the current node) or an absolute path (in the scene tree) to a node. If the path does not exist, a null instance
is returned and an error is logged. Attempts to access methods on the return value will result in an "Attempt to call <method> on a null instance." error.
Note: Fetching absolute paths only works when the node is inside the scene tree (see godot.Node.isInsideTree
).
Example: Assume your current node is Character and the following tree:
/root
/root/Character
/root/Character/Sword
/root/Character/Backpack/Dagger
/root/MyGame
/root/Swamp/Alligator
/root/Swamp/Mosquito
/root/Swamp/Goblin
Possible paths are:
get_node("Sword")
get_node("Backpack/Dagger")
get_node("../Swamp/Alligator")
get_node("/root/MyGame")
@:native("GetNodeAndResource")getNodeAndResource(path:NodePath):Array
Fetches a node and one of its resources as specified by the godot.NodePath
's subname (e.g. Area2D/CollisionShape2D:shape
). If several nested resources are specified in the godot.NodePath
, the last one will be fetched.
The return value is an array of size 3: the first index points to the godot.Node
(or null
if not found), the second index points to the godot.Resource
(or null
if not found), and the third index is the remaining godot.NodePath
, if any.
For example, assuming that Area2D/CollisionShape2D
is a valid node and that its shape
property has been assigned a godot.RectangleShape2D
resource, one could have this kind of output:
print(get_node_and_resource("Area2D/CollisionShape2D")) # [[CollisionShape2D:1161], Null, ]
print(get_node_and_resource("Area2D/CollisionShape2D:shape")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], ]
print(get_node_and_resource("Area2D/CollisionShape2D:shape:extents")) # [[CollisionShape2D:1161], [RectangleShape2D:1156], :extents]
@:native("GetNodeOrNull")getNodeOrNull(path:NodePath):Node
Similar to godot.Node.getNode
, but does not log an error if path
does not point to a valid godot.Node
.
@:native("GetParent")getParent():Node
Returns the parent node of the current node, or a null instance
if the node lacks a parent.
@:native("GetPath")getPath():NodePath
Returns the absolute path of the current node. This only works if the current node is inside the scene tree (see godot.Node.isInsideTree
).
@:native("GetPathTo")getPathTo(node:Node):NodePath
Returns the relative godot.NodePath
from this node to the specified node
. Both nodes must be in the same scene or the function will fail.
@:native("GetPhysicsProcessDeltaTime")getPhysicsProcessDeltaTime():Single
Returns the time elapsed (in seconds) since the last physics-bound frame (see godot.Node._PhysicsProcess
). This is always a constant value in physics processing unless the frames per second is changed via godot.Engine.iterationsPerSecond
.
@:native("GetPositionInParent")getPositionInParent():Int
Returns the node's order in the scene tree branch. For example, if called on the first child node the position is 0
.
@:native("GetProcessDeltaTime")getProcessDeltaTime():Single
Returns the time elapsed (in seconds) since the last process callback. This value may vary from frame to frame.
@:native("GetSceneInstanceLoadPlaceholder")getSceneInstanceLoadPlaceholder():Bool
Returns true
if this is an instance load placeholder. See godot.InstancePlaceholder
.
@:native("HasNode")hasNode(path:NodePath):Bool
Returns true
if the node that the godot.NodePath
points to exists.
@:native("HasNodeAndResource")hasNodeAndResource(path:NodePath):Bool
Returns true
if the godot.NodePath
points to a valid node and its subname points to a valid resource, e.g. Area2D/CollisionShape2D:shape
. Properties with a non-godot.Resource
type (e.g. nodes or primitive math types) are not considered resources.
@:native("IsAParentOf")isAParentOf(node:Node):Bool
Returns true
if the given node is a direct or indirect child of the current node.
@:native("IsDisplayedFolded")isDisplayedFolded():Bool
Returns true
if the node is folded (collapsed) in the Scene dock.
@:native("IsGreaterThan")isGreaterThan(node:Node):Bool
Returns true
if the given node occurs later in the scene hierarchy than the current node.
@:native("IsInGroup")isInGroup(group:String):Bool
Returns true
if this node is in the specified group. See notes in the description, and the group methods in godot.SceneTree
.
@:native("IsInsideTree")isInsideTree():Bool
Returns true
if this node is currently inside a godot.SceneTree
.
@:native("IsNetworkMaster")isNetworkMaster():Bool
Returns true
if the local system is the master of this node.
@:native("IsPhysicsProcessing")isPhysicsProcessing():Bool
Returns true
if physics processing is enabled (see godot.Node.setPhysicsProcess
).
@:native("IsPhysicsProcessingInternal")isPhysicsProcessingInternal():Bool
Returns true
if internal physics processing is enabled (see godot.Node.setPhysicsProcessInternal
).
@:native("IsProcessing")isProcessing():Bool
Returns true
if processing is enabled (see godot.Node.setProcess
).
@:native("IsProcessingInput")isProcessingInput():Bool
Returns true
if the node is processing input (see godot.Node.setProcessInput
).
@:native("IsProcessingInternal")isProcessingInternal():Bool
Returns true
if internal processing is enabled (see godot.Node.setProcessInternal
).
@:native("IsProcessingUnhandledInput")isProcessingUnhandledInput():Bool
Returns true
if the node is processing unhandled input (see godot.Node.setProcessUnhandledInput
).
@:native("IsProcessingUnhandledKeyInput")isProcessingUnhandledKeyInput():Bool
Returns true
if the node is processing unhandled key input (see godot.Node.setProcessUnhandledKeyInput
).
@:native("MoveChild")moveChild(childNode:Node, toPosition:Int):Void
Moves a child node to a different position (order) among the other children. Since calls, signals, etc are performed by tree order, changing the order of children nodes may be useful.
@:native("PrintStrayNodes")printStrayNodes():Void
Prints all stray nodes (nodes outside the godot.SceneTree
). Used for debugging. Works only in debug builds.
@:native("PrintTree")printTree():Void
Prints the tree to stdout. Used mainly for debugging purposes. This version displays the path relative to the current node, and is good for copy/pasting into the godot.Node.getNode
function.
Example output:
TheGame
TheGame/Menu
TheGame/Menu/Label
TheGame/Menu/Camera2D
TheGame/SplashScreen
TheGame/SplashScreen/Camera2D
@:native("PrintTreePretty")printTreePretty():Void
Similar to godot.Node.printTree
, this prints the tree to stdout. This version displays a more graphical representation similar to what is displayed in the scene inspector. It is useful for inspecting larger trees.
Example output:
â”–â•´TheGame
â” â•´Menu
┃ ┠╴Label
┃ ┖╴Camera2D
â”–â•´SplashScreen
â”–â•´Camera2D
@:native("PropagateCall")propagateCall(method:String, ?args:Array, ?parentFirst:Bool):Void
Calls the given method (if present) with the arguments given in args
on this node and recursively on all its children. If the parent_first
argument is true
, the method will be called on the current node first, then on all its children. If parent_first
is false
, the children will be called first.
Parameters:
args | If the parameter is null, then the default value is new Godot.Collections.Array { } |
---|
@:native("PropagateNotification")propagateNotification(what:Int):Void
Notifies the current node and all its children recursively by calling godot.Object.notification
on all of them.
@:native("QueueFree")queueFree():Void
Queues a node for deletion at the end of the current frame. When deleted, all of its child nodes will be deleted as well. This method ensures it's safe to delete the node, contrary to godot.Object.free
. Use godot.Object.isQueuedForDeletion
to check whether a node will be deleted at the end of the frame.
Important: If you have a variable pointing to a node, it will not be assigned to null
once the node 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.
@:native("Raise")raise():Void
Moves this node to the bottom of parent node's children hierarchy. This is often useful in GUIs (godot.Control
nodes), because their order of drawing depends on their order in the tree. The top Node is drawn first, then any siblings below the top Node in the hierarchy are successively drawn on top of it. After using raise
, a Control will be drawn on top of its siblings.
@:native("RemoveAndSkip")removeAndSkip():Void
Removes a node and sets all its children as children of the parent node (if it exists). All event subscriptions that pass by the removed node will be unsubscribed.
@:native("RemoveChild")removeChild(node:Node):Void
Removes a child node. The node is NOT deleted and must be deleted manually.
Note: This function may set the godot.Node.owner
of the removed Node (or its descendants) to be null
, if that godot.Node.owner
is no longer a parent or ancestor.
@:native("RemoveFromGroup")removeFromGroup(group:String):Void
Removes a node from a group. See notes in the description, and the group methods in godot.SceneTree
.
@:native("ReplaceBy")replaceBy(node:Node, ?keepData:Bool):Void
Replaces a node in a scene by the given one. Subscriptions that pass through this node will be lost.
Note that the replaced node is not automatically freed, so you either need to keep it in a variable for later use or free it using godot.Object.free
.
@:native("RequestReady")requestReady():Void
Requests that _ready
be called again. Note that the method won't be called immediately, but is scheduled for when the node is added to the scene tree again (see godot.Node._Ready
). _ready
is called only for the node which requested it, which means that you need to request ready for each child if you want them to call _ready
too (in which case, _ready
will be called in the same order as it would normally).
@:native("Rpc")rpc(method:String, args:HaxeArray<Dynamic>):Dynamic
Sends a remote procedure call request for the given method
to peers on the network (and locally), optionally sending all additional arguments as arguments to the method called by the RPC. The call request will only be received by nodes with the same godot.NodePath
, including the exact same node name. Behaviour depends on the RPC configuration for the given method, see godot.Node.rpcConfig
. Methods are not exposed to RPCs by default. See also godot.Node.rset
and godot.Node.rsetConfig
for properties. Returns null
.
Note: You can only safely use RPCs on clients after you received the connected_to_server
signal from the godot.SceneTree
. You also need to keep track of the connection state, either by the godot.SceneTree
signals like server_disconnected
or by checking SceneTree.network_peer.get_connection_status() == CONNECTION_CONNECTED
.
@:native("RpcConfig")rpcConfig(method:String, mode:MultiplayerAPI_RPCMode):Void
Changes the RPC mode for the given method
to the given mode
. See godot.MultiplayerAPI_RPCMode
. An alternative is annotating methods and properties with the corresponding keywords (remote
, master
, puppet
, remotesync
, mastersync
, puppetsync
). By default, methods are not exposed to networking (and RPCs). See also godot.Node.rset
and godot.Node.rsetConfig
for properties.
@:native("RpcId")rpcId(peerId:Int, method:String, args:HaxeArray<Dynamic>):Dynamic
Sends a godot.Node.rpc
to a specific peer identified by peer_id
(see godot.NetworkedMultiplayerPeer.setTargetPeer
). Returns null
.
@:native("RpcUnreliable")rpcUnreliable(method:String, args:HaxeArray<Dynamic>):Dynamic
Sends a godot.Node.rpc
using an unreliable protocol. Returns null
.
@:native("RpcUnreliableId")rpcUnreliableId(peerId:Int, method:String, args:HaxeArray<Dynamic>):Dynamic
Sends a godot.Node.rpc
to a specific peer identified by peer_id
using an unreliable protocol (see godot.NetworkedMultiplayerPeer.setTargetPeer
). Returns null
.
@:native("Rset")rset(property:String, value:Dynamic):Void
Remotely changes a property's value on other peers (and locally). Behaviour depends on the RPC configuration for the given property, see godot.Node.rsetConfig
. See also godot.Node.rpc
for RPCs for methods, most information applies to this method as well.
@:native("RsetConfig")rsetConfig(property:String, mode:MultiplayerAPI_RPCMode):Void
Changes the RPC mode for the given property
to the given mode
. See godot.MultiplayerAPI_RPCMode
. An alternative is annotating methods and properties with the corresponding keywords (remote
, master
, puppet
, remotesync
, mastersync
, puppetsync
). By default, properties are not exposed to networking (and RPCs). See also godot.Node.rpc
and godot.Node.rpcConfig
for methods.
@:native("RsetId")rsetId(peerId:Int, property:String, value:Dynamic):Void
Remotely changes the property's value on a specific peer identified by peer_id
(see godot.NetworkedMultiplayerPeer.setTargetPeer
).
@:native("RsetUnreliable")rsetUnreliable(property:String, value:Dynamic):Void
Remotely changes the property's value on other peers (and locally) using an unreliable protocol.
@:native("RsetUnreliableId")rsetUnreliableId(peerId:Int, property:String, value:Dynamic):Void
Remotely changes property's value on a specific peer identified by peer_id
using an unreliable protocol (see godot.NetworkedMultiplayerPeer.setTargetPeer
).
@:native("SetDisplayFolded")setDisplayFolded(fold:Bool):Void
Sets the folded state of the node in the Scene dock.
@:native("SetNetworkMaster")setNetworkMaster(id:Int, ?recursive:Bool):Void
Sets the node's network master to the peer with the given peer ID. The network master is the peer that has authority over the node on the network. Useful in conjunction with the master
and puppet
keywords. Inherited from the parent node by default, which ultimately defaults to peer ID 1 (the server). If recursive
, the given peer is recursively set as the master for all children of this node.
@:native("SetPhysicsProcess")setPhysicsProcess(enable:Bool):Void
Enables or disables physics (i.e. fixed framerate) processing. When a node is being processed, it will receive a godot.Node.notificationPhysicsProcess
at a fixed (usually 60 FPS, see godot.Engine.iterationsPerSecond
to change) interval (and the godot.Node._PhysicsProcess
callback will be called if exists). Enabled automatically if godot.Node._PhysicsProcess
is overridden. Any calls to this before godot.Node._Ready
will be ignored.
@:native("SetPhysicsProcessInternal")setPhysicsProcessInternal(enable:Bool):Void
Enables or disables internal physics for this node. Internal physics processing happens in isolation from the normal godot.Node._PhysicsProcess
calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or physics processing is disabled for scripting (godot.Node.setPhysicsProcess
). Only useful for advanced uses to manipulate built-in nodes' behavior.
Warning: Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported.
@:native("SetProcess")setProcess(enable:Bool):Void
Enables or disables processing. When a node is being processed, it will receive a godot.Node.notificationProcess
on every drawn frame (and the godot.Node._Process
callback will be called if exists). Enabled automatically if godot.Node._Process
is overridden. Any calls to this before godot.Node._Ready
will be ignored.
@:native("SetProcessInput")setProcessInput(enable:Bool):Void
Enables or disables input processing. This is not required for GUI controls! Enabled automatically if godot.Node._Input
is overridden. Any calls to this before godot.Node._Ready
will be ignored.
@:native("SetProcessInternal")setProcessInternal(enable:Bool):Void
Enables or disabled internal processing for this node. Internal processing happens in isolation from the normal godot.Node._Process
calls and is used by some nodes internally to guarantee proper functioning even if the node is paused or processing is disabled for scripting (godot.Node.setProcess
). Only useful for advanced uses to manipulate built-in nodes' behavior.
Warning: Built-in Nodes rely on the internal processing for their own logic, so changing this value from your code may lead to unexpected behavior. Script access to this internal logic is provided for specific advanced uses, but is unsafe and not supported.
@:native("SetProcessUnhandledInput")setProcessUnhandledInput(enable:Bool):Void
Enables unhandled input processing. This is not required for GUI controls! It enables the node to receive all input that was not previously handled (usually by a godot.Control
). Enabled automatically if godot.Node._UnhandledInput
is overridden. Any calls to this before godot.Node._Ready
will be ignored.
@:native("SetProcessUnhandledKeyInput")setProcessUnhandledKeyInput(enable:Bool):Void
Enables unhandled key input processing. Enabled automatically if godot.Node._UnhandledKeyInput
is overridden. Any calls to this before godot.Node._Ready
will be ignored.
@:native("SetSceneInstanceLoadPlaceholder")setSceneInstanceLoadPlaceholder(loadPlaceholder:Bool):Void
Sets whether this is an instance load placeholder. See godot.InstancePlaceholder
.
@:native("UpdateConfigurationWarning")updateConfigurationWarning():Void
Updates the warning displayed for this node in the Scene Dock.
Use godot.Node._GetConfigurationWarning
to setup the warning message to display.
Defined by Object
@:native("_Get")_Get(property:String):Dynamic
Virtual method which can be overridden to customize the return value of godot.Object.get
.
Returns the given property. Returns null
if the property
does not exist.
@:native("_GetPropertyList")_GetPropertyList():Array
Virtual method which can be overridden to customize the return value of godot.Object.getPropertyList
.
Returns the object's property list as an godot.Collections_Array
of dictionaries.
Each property's godot.Collections_Dictionary
must contain at least name: String
and type: int
(see godot.Variant_Type
) entries. Optionally, it can also include hint: int
(see godot.PropertyHint
), hint_string: String
, and usage: int
(see godot.PropertyUsageFlags
).
@:native("_Notification")_Notification(what:Int):Void
Called whenever the object receives a notification, which is identified in what
by a constant. The base godot.Object
has two constants godot.Object.notificationPostinitialize
and godot.Object.notificationPredelete
, but subclasses such as godot.Node
define a lot more notifications which are also received by this method.
@:native("_Set")_Set(property:String, value:Dynamic):Bool
Virtual method which can be overridden to customize the return value of godot.Object.set
.
Sets a property. Returns true
if the property
exists.
@:native("AddUserSignal")addUserSignal(signal:String, ?arguments:Array):Void
Adds a user-defined signal
. Arguments are optional, but can be added as an godot.Collections_Array
of dictionaries, each containing name: String
and type: int
(see godot.Variant_Type
) entries.
Parameters:
arguments | If the parameter is null, then the default value is new Godot.Collections.Array { } |
---|
@:native("Call")call(method:String, args:HaxeArray<Dynamic>):Dynamic
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).
@:native("CallDeferred")callDeferred(method:String, args:HaxeArray<Dynamic>):Void
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).
@:native("Callv")callv(method:String, argArray:Array):Dynamic
Calls the method
on the object and returns the result. Contrarily to godot.Object.call
, this method does not support a variable number of arguments but expects all parameters to be via a single godot.Collections_Array
.
callv("set", [ "position", Vector2(42.0, 0.0) ])
@:native("CanTranslateMessages")canTranslateMessages():Bool
Returns true
if the object can translate strings. See godot.Object.setMessageTranslation
and godot.Object.tr
.
@:native("Connect")connect(signal:String, target:Object, method:String, ?binds:Array, ?flags:UInt):Error
Connects a signal
to a method
on a target
object. Pass optional binds
to the call as an godot.Collections_Array
of parameters. These parameters will be passed to the method after any parameter used in the call to godot.Object.emitSignal
. Use flags
to set deferred or one-shot connections. See godot.Object_ConnectFlags
constants.
A signal
can only be connected once to a method
. It will print an error if already connected, unless the signal was connected with godot.Object_ConnectFlags.referenceCounted
. To avoid this, first, use godot.Object.isConnected
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 godot.Object.connect
and parameters used when calling godot.Object.emitSignal
:
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])
Parameters:
binds | If the parameter is null, then the default value is new Godot.Collections.Array { } |
---|
@:native("Disconnect")disconnect(signal:String, target:Object, method:String):Void
Disconnects a signal
from a method
on the given target
.
If you try to disconnect a connection that does not exist, the method will print an error. Use godot.Object.isConnected
to ensure that the connection exists.
@:native("Dispose")dispose():Void
@:native("Dispose")@:protectedDispose(disposing:Bool):Void
Disposes of this godot.Object
.
@:native("EmitSignal")emitSignal(signal:String, args:HaxeArray<Dynamic>):Void
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")
@:native("Free")free():Void
Deletes the object from memory immediately. For godot.Node
s, you may want to use godot.Node.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.
@:native("Get")get(property:String):Dynamic
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).
@:native("GetClass")getClass():String
Returns the object's class as a String
. See also godot.Object.isClass
.
Note: godot.Object.getClass
does not take class_name
declarations into account. If the object has a class_name
defined, the base class name will be returned instead.
@:native("GetIncomingConnections")getIncomingConnections():Array
Returns an godot.Collections_Array
of dictionaries with information about signals that are connected to the object.
Each godot.Collections_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.
@:native("GetIndexed")getIndexed(property:NodePath):Dynamic
Gets the object's property indexed by the given godot.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"
.
Note: Even though the method takes godot.NodePath
argument, it doesn't support actual paths to godot.Node
s in the scene tree, only colon-separated sub-property paths. For the purpose of nodes, use godot.Node.getNodeAndResource
instead.
@:native("GetInstanceId")getInstanceId():UInt64
Returns the object's unique instance ID.
This ID can be saved in godot.EncodedObjectAsID
, and can be used to retrieve the object instance with @GDScript.instance_from_id
.
@:native("GetMeta")getMeta(name:String):Dynamic
Returns the object's metadata entry for the given name
.
@:native("GetMethodList")getMethodList():Array
Returns the object's methods and their signatures as an godot.Collections_Array
.
@:native("GetPropertyList")getPropertyList():Array
Returns the object's property list as an godot.Collections_Array
of dictionaries.
Each property's godot.Collections_Dictionary
contain at least name: String
and type: int
(see godot.Variant_Type
) entries. Optionally, it can also include hint: int
(see godot.PropertyHint
), hint_string: String
, and usage: int
(see godot.PropertyUsageFlags
).
@:native("GetScript")getScript():Reference
Returns the object's godot.Script
instance, or null
if none is assigned.
@:native("GetSignalConnectionList")getSignalConnectionList(signal:String):Array
Returns an godot.Collections_Array
of connections for the given signal
.
@:native("GetSignalList")getSignalList():Array
Returns the list of signals as an godot.Collections_Array
of dictionaries.
@:native("HasMeta")hasMeta(name:String):Bool
Returns true
if a metadata entry is found with the given name
.
@:native("HasMethod")hasMethod(method:String):Bool
Returns true
if the object contains the given method
.
@:native("HasUserSignal")hasUserSignal(signal:String):Bool
Returns true
if the given user-defined signal
exists. Only signals added using godot.Object.addUserSignal
are taken into account.
@:native("IsBlockingSignals")isBlockingSignals():Bool
Returns true
if signal emission blocking is enabled.
@:native("IsClass")isClass(class_:String):Bool
Returns true
if the object inherits from the given class
. See also godot.Object.getClass
.
Note: godot.Object.isClass
does not take class_name
declarations into account. If the object has a class_name
defined, godot.Object.isClass
will return false
for that name.
@:native("IsConnected")isConnected(signal:String, target:Object, method:String):Bool
Returns true
if a connection exists for a given signal
, target
, and method
.
@:native("IsQueuedForDeletion")isQueuedForDeletion():Bool
Returns true
if the godot.Node.queueFree
method was called for the object.
@:native("Notification")notification(what:Int, ?reversed:Bool):Void
Send a given notification to the object, which will also trigger a call to the godot.Object._Notification
method of all classes that the object inherits from.
If reversed
is true
, godot.Object._Notification
is called first on the object's own class, and then up to its successive parent classes. If reversed
is false
, godot.Object._Notification
is called first on the highest ancestor (godot.Object
itself), and then down to its successive inheriting classes.
@:native("PropertyListChangedNotify")propertyListChangedNotify():Void
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.
@:native("RemoveMeta")removeMeta(name:String):Void
Removes a given entry from the object's metadata. See also godot.Object.setMeta
.
@:native("Set")set(property:String, value:Dynamic):Void
Assigns a new value to the given property. If the property
does not exist or the given value's type doesn't match, 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).
@:native("SetBlockSignals")setBlockSignals(enable:Bool):Void
If set to true
, signal emission is blocked.
@:native("SetDeferred")setDeferred(property:String, value:Dynamic):Void
Assigns a new value to the given property, after the current frame's physics step. This is equivalent to calling godot.Object.set
via godot.Object.callDeferred
, 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).
@:native("SetIndexed")setIndexed(property:NodePath, value:Dynamic):Void
Assigns a new value to the property identified by the godot.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)
@:native("SetMessageTranslation")setMessageTranslation(enable:Bool):Void
Defines whether the object can translate strings (with calls to godot.Object.tr
). Enabled by default.
@:native("SetMeta")setMeta(name:String, value:Dynamic):Void
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 godot.Object.removeMeta
. 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"
.
@:native("SetScript")setScript(script:Reference):Void
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.
@:native("ToSignal")toSignal(source:Object, signal:String):SignalAwaiter
Returns a new godot.SignalAwaiter
awaiter configured to complete when the instance
source
emits the signal specified by the signal
parameter.
Parameters:
source | The instance the awaiter will be listening to. |
---|---|
signal | The signal the awaiter will be waiting for. This sample prints a message once every frame up to 100 times.
|
Returns:
A godot.SignalAwaiter
that completes when
source
emits the signal
.
@:native("ToString")toString():String
@:native("Tr")tr(message:String):String
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 godot.Object.setMessageTranslation
.