Control

package
v0.0.0-...-c858641 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2025 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Base class for all UI-related nodes. graphics.gd/classdb/Control features a bounding rectangle that defines its extents, an anchor position relative to its parent control or the current viewport, and offsets relative to the anchor. The offsets update automatically when the node, any of its parents, or the screen size change.

For more information on Godot's UI system, anchors, offsets, and containers, see the related tutorials in the manual. To build flexible UIs, you'll need a mix of UI elements that inherit from graphics.gd/classdb/Control and graphics.gd/classdb/Container nodes.

Note: Since both graphics.gd/classdb/Node2D and graphics.gd/classdb/Control inherit from graphics.gd/classdb/CanvasItem, they share several concepts from the class such as the graphics.gd/classdb/CanvasItem.Instance.ZIndex and graphics.gd/classdb/CanvasItem.Instance.Visible properties.

User Interface nodes and input

Godot propagates input events via viewports. Each graphics.gd/classdb/Viewport is responsible for propagating [graphics.gd/classdb/InputEvent]s to their child nodes. As the graphics.gd/classdb/SceneTree.Instance.Root is a graphics.gd/classdb/Window, this already happens automatically for all UI elements in your game.

Input events are propagated through the graphics.gd/classdb/SceneTree from the root node to all child nodes by calling graphics.gd/classdb/Node.Instance.Input. For UI elements specifically, it makes more sense to override the virtual method [Interface.GuiInput], which filters out unrelated input events, such as by checking z-order, Instance.MouseFilter, focus, or if the event was inside of the control's bounding box.

Call Instance.AcceptEvent so no other node receives the event. Once you accept an input, it becomes handled so graphics.gd/classdb/Node.Instance.UnhandledInput will not process it.

Only one graphics.gd/classdb/Control node can be in focus. Only the node in focus will receive events. To get the focus, call Instance.GrabFocus. graphics.gd/classdb/Control nodes lose focus when another node grabs it, or if you hide the node in focus.

Sets Instance.MouseFilter to MouseFilterIgnore to tell a graphics.gd/classdb/Control node to ignore mouse or touch events. You'll need it if you place an icon on top of a button.

graphics.gd/classdb/Theme resources change the control's appearance. The Instance.Theme of a graphics.gd/classdb/Control node affects all of its direct and indirect children (as long as a chain of controls is uninterrupted). To override some of the theme items, call one of the add_theme_*_override methods, like Instance.AddThemeFontOverride. You can also override theme items in the Inspector.

Note: Theme items are not graphics.gd/classdb/Object properties. This means you can't access their values using graphics.gd/classdb/Object.Instance.Get and graphics.gd/classdb/Object.Instance.Set. Instead, use the get_theme_* and add_theme_*_override methods provided by this class.

Index

Constants

View Source
const NotificationFocusEnter Object.Notification = 43 //gd:Control.NOTIFICATION_FOCUS_ENTER
View Source
const NotificationFocusExit Object.Notification = 44 //gd:Control.NOTIFICATION_FOCUS_EXIT
View Source
const NotificationLayoutDirectionChanged Object.Notification = 49 //gd:Control.NOTIFICATION_LAYOUT_DIRECTION_CHANGED
View Source
const NotificationMouseEnter Object.Notification = 41 //gd:Control.NOTIFICATION_MOUSE_ENTER
View Source
const NotificationMouseEnterSelf Object.Notification = 60 //gd:Control.NOTIFICATION_MOUSE_ENTER_SELF
View Source
const NotificationMouseExit Object.Notification = 42 //gd:Control.NOTIFICATION_MOUSE_EXIT
View Source
const NotificationMouseExitSelf Object.Notification = 61 //gd:Control.NOTIFICATION_MOUSE_EXIT_SELF
View Source
const NotificationResized Object.Notification = 40 //gd:Control.NOTIFICATION_RESIZED
View Source
const NotificationScrollBegin Object.Notification = 47 //gd:Control.NOTIFICATION_SCROLL_BEGIN
View Source
const NotificationScrollEnd Object.Notification = 48 //gd:Control.NOTIFICATION_SCROLL_END
View Source
const NotificationThemeChanged Object.Notification = 45 //gd:Control.NOTIFICATION_THEME_CHANGED

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

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

type Anchor

type Anchor int //gd:Control.Anchor
const (
	// Snaps one of the 4 anchor's sides to the origin of the node's Rect, in the top left. Use it with one of the anchor_* member variables, like [Instance.AnchorLeft]. To change all 4 anchors at once, use [Instance.SetAnchorsPreset].
	AnchorBegin Anchor = 0
	// Snaps one of the 4 anchor's sides to the end of the node's Rect, in the bottom right. Use it with one of the anchor_* member variables, like [Instance.AnchorLeft]. To change all 4 anchors at once, use [Instance.SetAnchorsPreset].
	AnchorEnd Anchor = 1
)

type Any

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

type CursorShape

type CursorShape int //gd:Control.CursorShape
const (
	// Show the system's arrow mouse cursor when the user hovers the node. Use with [Instance.MouseDefaultCursorShape].
	CursorArrow CursorShape = 0
	// Show the system's I-beam mouse cursor when the user hovers the node. The I-beam pointer has a shape similar to "I". It tells the user they can highlight or insert text.
	CursorIbeam CursorShape = 1
	// Show the system's pointing hand mouse cursor when the user hovers the node.
	CursorPointingHand CursorShape = 2
	// Show the system's cross mouse cursor when the user hovers the node.
	CursorCross CursorShape = 3
	// Show the system's wait mouse cursor when the user hovers the node. Often an hourglass.
	CursorWait CursorShape = 4
	// Show the system's busy mouse cursor when the user hovers the node. Often an arrow with a small hourglass.
	CursorBusy CursorShape = 5
	// Show the system's drag mouse cursor, often a closed fist or a cross symbol, when the user hovers the node. It tells the user they're currently dragging an item, like a node in the Scene dock.
	CursorDrag CursorShape = 6
	// Show the system's drop mouse cursor when the user hovers the node. It can be an open hand. It tells the user they can drop an item they're currently grabbing, like a node in the Scene dock.
	CursorCanDrop CursorShape = 7
	// Show the system's forbidden mouse cursor when the user hovers the node. Often a crossed circle.
	CursorForbidden CursorShape = 8
	// Show the system's vertical resize mouse cursor when the user hovers the node. A double-headed vertical arrow. It tells the user they can resize the window or the panel vertically.
	CursorVsize CursorShape = 9
	// Show the system's horizontal resize mouse cursor when the user hovers the node. A double-headed horizontal arrow. It tells the user they can resize the window or the panel horizontally.
	CursorHsize CursorShape = 10
	// Show the system's window resize mouse cursor when the user hovers the node. The cursor is a double-headed arrow that goes from the bottom left to the top right. It tells the user they can resize the window or the panel both horizontally and vertically.
	CursorBdiagsize CursorShape = 11
	// Show the system's window resize mouse cursor when the user hovers the node. The cursor is a double-headed arrow that goes from the top left to the bottom right, the opposite of [CursorBdiagsize]. It tells the user they can resize the window or the panel both horizontally and vertically.
	CursorFdiagsize CursorShape = 12
	// Show the system's move mouse cursor when the user hovers the node. It shows 2 double-headed arrows at a 90 degree angle. It tells the user they can move a UI element freely.
	CursorMove CursorShape = 13
	// Show the system's vertical split mouse cursor when the user hovers the node. On Windows, it's the same as [CursorVsize].
	CursorVsplit CursorShape = 14
	// Show the system's horizontal split mouse cursor when the user hovers the node. On Windows, it's the same as [CursorHsize].
	CursorHsplit CursorShape = 15
	// Show the system's help mouse cursor when the user hovers the node, a question mark.
	CursorHelp CursorShape = 16
)

type Expanded

type Expanded [1]gdclass.Control

func (Expanded) GetCursorShape

func (self Expanded) GetCursorShape(position Vector2.XY) CursorShape

Returns the mouse cursor shape the control displays on mouse hover. See CursorShape.

func (Expanded) GetThemeColor

func (self Expanded) GetThemeColor(name string, theme_type string) Color.RGBA

Returns a [Color.RGBA] from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/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, or Instance.ThemeTypeVariation if it is defined. If the type is a class name its parent classes are also checked, in order of inheritance. If the type is a variation its base types are checked, in order of dependency, then the control's class name and its parent classes are checked.

For the current control its local overrides are considered first (see Instance.AddThemeColorOverride), then its assigned Instance.Theme. After the current control, each parent control and its assigned Instance.Theme are considered; controls without a Instance.Theme assigned are skipped. If no matching graphics.gd/classdb/Theme is found in the tree, the custom project graphics.gd/classdb/Theme (see graphics.gd/classdb/ProjectSettings "gui/theme/custom") and the default graphics.gd/classdb/Theme are used (see graphics.gd/classdb/ThemeDB).

// Get the font color defined for the current Control's class, if it exists.
control.AsCanvasItem().SetModulate(control.GetThemeColor("font_color"))
// Get the font color defined for the Button class.
control.AsCanvasItem().SetModulate(Control.Expanded(control).GetThemeColor("font_color", "Button"))

func (Expanded) GetThemeConstant

func (self Expanded) GetThemeConstant(name string, theme_type string) int

Returns a constant from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a constant item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) GetThemeFont

func (self Expanded) GetThemeFont(name string, theme_type string) Font.Instance

Returns a graphics.gd/classdb/Font from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a font item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) GetThemeFontSize

func (self Expanded) GetThemeFontSize(name string, theme_type string) int

Returns a font size from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a font size item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) GetThemeIcon

func (self Expanded) GetThemeIcon(name string, theme_type string) Texture2D.Instance

Returns an icon from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has an icon item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) GetThemeStylebox

func (self Expanded) GetThemeStylebox(name string, theme_type string) StyleBox.Instance

Returns a graphics.gd/classdb/StyleBox from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a stylebox item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) GetTooltip

func (self Expanded) GetTooltip(at_position Vector2.XY) string

Returns the tooltip text for the position 'at_position' in control's local coordinates, which will typically appear when the cursor is resting over this control. By default, it returns Instance.TooltipText.

This method can be overridden to customize its behavior. See [Interface.GetTooltip].

Note: If this method returns an empty string and [Interface.MakeCustomTooltip] is not overridden, no tooltip is displayed.

func (Expanded) HasThemeColor

func (self Expanded) HasThemeColor(name string, theme_type string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has a color item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) HasThemeConstant

func (self Expanded) HasThemeConstant(name string, theme_type string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has a constant item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) HasThemeFont

func (self Expanded) HasThemeFont(name string, theme_type string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has a font item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) HasThemeFontSize

func (self Expanded) HasThemeFontSize(name string, theme_type string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has a font size item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) HasThemeIcon

func (self Expanded) HasThemeIcon(name string, theme_type string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has an icon item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) HasThemeStylebox

func (self Expanded) HasThemeStylebox(name string, theme_type string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has a stylebox item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Expanded) SetAnchor

func (self Expanded) SetAnchor(side Rect2.Side, anchor Float.X, keep_offset bool, push_opposite_anchor bool)

Sets the anchor for the specified [Side] to 'anchor'. A setter method for Instance.AnchorBottom, Instance.AnchorLeft, Instance.AnchorRight and Instance.AnchorTop.

If 'keep_offset' is true, offsets 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.

func (Expanded) SetAnchorAndOffset

func (self Expanded) SetAnchorAndOffset(side Rect2.Side, anchor Float.X, offset Float.X, push_opposite_anchor bool)

Works the same as Instance.SetAnchor, but instead of keep_offset argument and automatic update of offset, it allows to set the offset yourself (see [Instance.SetOffset]).

func (Expanded) SetAnchorsAndOffsetsPreset

func (self Expanded) SetAnchorsAndOffsetsPreset(preset LayoutPreset, resize_mode LayoutPresetMode, margin int)

Sets both anchor preset and offset preset. See Instance.SetAnchorsPreset and Instance.SetOffsetsPreset.

func (Expanded) SetAnchorsPreset

func (self Expanded) SetAnchorsPreset(preset LayoutPreset, keep_offsets bool)

Sets the anchors to a 'preset' from [Control.LayoutPreset] enum. This is the code equivalent to using the Layout menu in the 2D editor.

If 'keep_offsets' is true, control's position will also be updated.

func (Expanded) SetGlobalPosition

func (self Expanded) SetGlobalPosition(position Vector2.XY, keep_offsets bool)

Sets the Instance.GlobalPosition to given 'position'.

If 'keep_offsets' is true, control's anchors will be updated instead of offsets.

func (Expanded) SetOffsetsPreset

func (self Expanded) SetOffsetsPreset(preset LayoutPreset, resize_mode LayoutPresetMode, margin int)

Sets the offsets to a 'preset' from [Control.LayoutPreset] enum. This is the code equivalent to using the Layout menu in the 2D editor.

Use parameter 'resize_mode' with constants from [Control.LayoutPresetMode] to better determine the resulting size of the graphics.gd/classdb/Control. Constant size will be ignored if used with presets that change size, e.g. PresetLeftWide.

Use parameter 'margin' to determine the gap between the graphics.gd/classdb/Control and the edges.

func (Expanded) SetPosition

func (self Expanded) SetPosition(position Vector2.XY, keep_offsets bool)

Sets the Instance.Position to given 'position'.

If 'keep_offsets' is true, control's anchors will be updated instead of offsets.

func (Expanded) SetSize

func (self Expanded) SetSize(size Vector2.XY, keep_offsets bool)

Sets the size (see Instance.Size).

If 'keep_offsets' is true, control's anchors will be updated instead of offsets.

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this [Extension]See Interface for methods that can be overridden by T.

func (*Extension[T]) AsCanvasItem

func (self *Extension[T]) AsCanvasItem() CanvasItem.Instance

func (*Extension[T]) AsControl

func (self *Extension[T]) AsControl() Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

type FocusMode

type FocusMode int //gd:Control.FocusMode
const (
	// The node cannot grab focus. Use with [Instance.FocusMode].
	FocusNone FocusMode = 0
	// The node can only grab focus on mouse clicks. Use with [Instance.FocusMode].
	FocusClick FocusMode = 1
	// The node can grab focus on mouse click, using the arrows and the Tab keys on the keyboard, or using the D-pad buttons on a gamepad. Use with [Instance.FocusMode].
	FocusAll FocusMode = 2
)

type GrowDirection

type GrowDirection int //gd:Control.GrowDirection
const (
	// The control will grow to the left or top to make up if its minimum size is changed to be greater than its current size on the respective axis.
	GrowDirectionBegin GrowDirection = 0
	// The control will grow to the right or bottom to make up if its minimum size is changed to be greater than its current size on the respective axis.
	GrowDirectionEnd GrowDirection = 1
	// The control will grow in both directions equally to make up if its minimum size is changed to be greater than its current size.
	GrowDirectionBoth GrowDirection = 2
)

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.Control

Instance of the class with convieniently typed arguments and results.

var Nil Instance

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

func New

func New() Instance

func (Instance) AcceptEvent

func (self Instance) AcceptEvent()

Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to graphics.gd/classdb/Node.Instance.UnhandledInput or graphics.gd/classdb/Node.Instance.UnhandledKeyInput.

Note: This does not affect the methods in graphics.gd/classdb/Input, only the way events are propagated.

func (Instance) AddThemeColorOverride

func (self Instance) AddThemeColorOverride(name string, color Color.RGBA)

Creates a local override for a theme [Color.RGBA] with the specified 'name'. Local overrides always take precedence when fetching theme items for the control. An override can be removed with Instance.RemoveThemeColorOverride.

See also Instance.GetThemeColor.

Example: Override a graphics.gd/classdb/Label's color and reset it later:

// Given the child Label node "MyLabel", override its font color with a custom value.
MyLabel.AsControl().AddThemeColorOverride("font_color", Color.RGBA{1, 0.5, 0, 1})
// Reset the font color of the child label.
MyLabel.AsControl().RemoveThemeColorOverride("font_color")
// Alternatively it can be overridden with the default value from the Label type.
MyLabel.AsControl().AddThemeColorOverride("font_color", Control.Expanded(MyLabel.AsControl()).GetThemeColor("font_color", "Label"))

func (Instance) AddThemeConstantOverride

func (self Instance) AddThemeConstantOverride(name string, constant int)

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 can be removed with Instance.RemoveThemeConstantOverride.

See also Instance.GetThemeConstant.

func (Instance) AddThemeFontOverride

func (self Instance) AddThemeFontOverride(name string, font Font.Instance)

Creates a local override for a theme graphics.gd/classdb/Font with the specified 'name'. Local overrides always take precedence when fetching theme items for the control. An override can be removed with Instance.RemoveThemeFontOverride.

See also Instance.GetThemeFont.

func (Instance) AddThemeFontSizeOverride

func (self Instance) AddThemeFontSizeOverride(name string, font_size int)

Creates a local override for a theme font size with the specified 'name'. Local overrides always take precedence when fetching theme items for the control. An override can be removed with Instance.RemoveThemeFontSizeOverride.

See also Instance.GetThemeFontSize.

func (Instance) AddThemeIconOverride

func (self Instance) AddThemeIconOverride(name string, texture Texture2D.Instance)

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 with Instance.RemoveThemeIconOverride.

See also Instance.GetThemeIcon.

func (Instance) AddThemeStyleboxOverride

func (self Instance) AddThemeStyleboxOverride(name string, stylebox StyleBox.Instance)

Creates a local override for a theme graphics.gd/classdb/StyleBox with the specified 'name'. Local overrides always take precedence when fetching theme items for the control. An override can be removed with Instance.RemoveThemeStyleboxOverride.

See also Instance.GetThemeStylebox.

Example: Modify a property in a graphics.gd/classdb/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 newStyleboxNormal = Resource.Duplicate(MyButton.AsControl().GetThemeStylebox("normal"))
Object.Set(newStyleboxNormal, "border_width_top", 3)
Object.Set(newStyleboxNormal, "border_color", Color.RGBA{0, 1, 0.5, 1})
MyButton.AsControl().AddThemeStyleboxOverride("normal", newStyleboxNormal)
// Remove the stylebox override.
MyButton.AsControl().RemoveThemeStyleboxOverride("normal")

func (Instance) AnchorBottom

func (self Instance) AnchorBottom() Float.X

func (Instance) AnchorLeft

func (self Instance) AnchorLeft() Float.X

func (Instance) AnchorRight

func (self Instance) AnchorRight() Float.X

func (Instance) AnchorTop

func (self Instance) AnchorTop() Float.X

func (Instance) AsCanvasItem

func (self Instance) AsCanvasItem() CanvasItem.Instance

func (Instance) AsControl

func (self Instance) AsControl() Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsObject

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

func (Instance) AutoTranslate

func (self Instance) AutoTranslate() bool

func (Instance) BeginBulkThemeOverride

func (self Instance) BeginBulkThemeOverride()

Prevents *_theme_*_override methods from emitting NotificationThemeChanged until Instance.EndBulkThemeOverride is called.

func (Instance) ClipContents

func (self Instance) ClipContents() bool

func (Instance) CustomMinimumSize

func (self Instance) CustomMinimumSize() Vector2.XY

func (Instance) EndBulkThemeOverride

func (self Instance) EndBulkThemeOverride()

Ends a bulk theme override update. See Instance.BeginBulkThemeOverride.

func (Instance) FindNextValidFocus

func (self Instance) FindNextValidFocus() Instance

Finds the next (below in the tree) graphics.gd/classdb/Control that can receive the focus.

func (Instance) FindPrevValidFocus

func (self Instance) FindPrevValidFocus() Instance

Finds the previous (above in the tree) graphics.gd/classdb/Control that can receive the focus.

func (Instance) FindValidFocusNeighbor

func (self Instance) FindValidFocusNeighbor(side Rect2.Side) Instance

Finds the next graphics.gd/classdb/Control that can receive the focus on the specified [Side].

Note: This is different from [Instance.GetFocusNeighbor], which returns the path of a specified focus neighbor.

func (Instance) FocusMode

func (self Instance) FocusMode() FocusMode

func (Instance) FocusNeighborBottom

func (self Instance) FocusNeighborBottom() string

func (Instance) FocusNeighborLeft

func (self Instance) FocusNeighborLeft() string

func (Instance) FocusNeighborRight

func (self Instance) FocusNeighborRight() string

func (Instance) FocusNeighborTop

func (self Instance) FocusNeighborTop() string

func (Instance) FocusNext

func (self Instance) FocusNext() string

func (Instance) FocusPrevious

func (self Instance) FocusPrevious() string

func (Instance) ForceDrag

func (self Instance) ForceDrag(data any, preview Instance)

Forces drag and bypasses [Interface.GetDragData] and Instance.SetDragPreview by passing 'data' and 'preview'. Drag will start even if the mouse is neither over nor pressed on this control.

The methods [Interface.CanDropData] and [Interface.DropData] must be implemented on controls that want to receive drop data.

func (Instance) GetBegin

func (self Instance) GetBegin() Vector2.XY

Returns Instance.OffsetLeft and Instance.OffsetTop. See also Instance.Position.

func (Instance) GetCombinedMinimumSize

func (self Instance) GetCombinedMinimumSize() Vector2.XY

Returns combined minimum size from Instance.CustomMinimumSize and Instance.GetMinimumSize.

func (Instance) GetCursorShape

func (self Instance) GetCursorShape() CursorShape

Returns the mouse cursor shape the control displays on mouse hover. See CursorShape.

func (Instance) GetEnd

func (self Instance) GetEnd() Vector2.XY

Returns Instance.OffsetRight and Instance.OffsetBottom.

func (Instance) GetGlobalRect

func (self Instance) GetGlobalRect() Rect2.PositionSize

Returns the position and size of the control relative to the containing canvas. See Instance.GlobalPosition and Instance.Size.

Note: If the node itself or any parent graphics.gd/classdb/CanvasItem between the node and the canvas have a non default rotation or skew, the resulting size is likely not meaningful.

Note: Setting graphics.gd/classdb/Viewport.Instance.GuiSnapControlsToPixels to true can lead to rounding inaccuracies between the displayed control and the returned [Rect2.PositionSize].

func (Instance) GetMinimumSize

func (self Instance) GetMinimumSize() Vector2.XY

Returns the minimum size for this control. See Instance.CustomMinimumSize.

func (Instance) GetParentAreaSize

func (self Instance) GetParentAreaSize() Vector2.XY

Returns the width/height occupied in the parent control.

func (Instance) GetParentControl

func (self Instance) GetParentControl() Instance

Returns the parent control node.

func (Instance) GetRect

func (self Instance) GetRect() Rect2.PositionSize

Returns the position and size of the control in the coordinate system of the containing node. See Instance.Position, Instance.Scale and Instance.Size.

Note: If Instance.Rotation is not the default rotation, the resulting size is not meaningful.

Note: Setting graphics.gd/classdb/Viewport.Instance.GuiSnapControlsToPixels to true can lead to rounding inaccuracies between the displayed control and the returned [Rect2.PositionSize].

func (Instance) GetScreenPosition

func (self Instance) GetScreenPosition() Vector2.XY

Returns the position of this graphics.gd/classdb/Control in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.

Equals to Instance.GlobalPosition if the window is embedded (see graphics.gd/classdb/Viewport.Instance.GuiEmbedSubwindows).

Example: Show a popup at the mouse position:

popup_menu.AsWindow().SetPosition(Vector2i.From(Vector2.Add(control.GetScreenPosition(), control.AsCanvasItem().GetLocalMousePosition())))
popup_menu.AsWindow().ResetSize()
popup_menu.AsWindow().Popup()

func (Instance) GetThemeColor

func (self Instance) GetThemeColor(name string) Color.RGBA

Returns a [Color.RGBA] from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/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, or Instance.ThemeTypeVariation if it is defined. If the type is a class name its parent classes are also checked, in order of inheritance. If the type is a variation its base types are checked, in order of dependency, then the control's class name and its parent classes are checked.

For the current control its local overrides are considered first (see Instance.AddThemeColorOverride), then its assigned Instance.Theme. After the current control, each parent control and its assigned Instance.Theme are considered; controls without a Instance.Theme assigned are skipped. If no matching graphics.gd/classdb/Theme is found in the tree, the custom project graphics.gd/classdb/Theme (see graphics.gd/classdb/ProjectSettings "gui/theme/custom") and the default graphics.gd/classdb/Theme are used (see graphics.gd/classdb/ThemeDB).

// Get the font color defined for the current Control's class, if it exists.
control.AsCanvasItem().SetModulate(control.GetThemeColor("font_color"))
// Get the font color defined for the Button class.
control.AsCanvasItem().SetModulate(Control.Expanded(control).GetThemeColor("font_color", "Button"))

func (Instance) GetThemeConstant

func (self Instance) GetThemeConstant(name string) int

Returns a constant from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a constant item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) GetThemeDefaultBaseScale

func (self Instance) GetThemeDefaultBaseScale() Float.X

Returns the default base scale value from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a valid graphics.gd/classdb/Theme.Instance.DefaultBaseScale value.

See Instance.GetThemeColor for details.

func (Instance) GetThemeDefaultFont

func (self Instance) GetThemeDefaultFont() Font.Instance

Returns the default font from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a valid graphics.gd/classdb/Theme.Instance.DefaultFont value.

See Instance.GetThemeColor for details.

func (Instance) GetThemeDefaultFontSize

func (self Instance) GetThemeDefaultFontSize() int

Returns the default font size value from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a valid graphics.gd/classdb/Theme.Instance.DefaultFontSize value.

See Instance.GetThemeColor for details.

func (Instance) GetThemeFont

func (self Instance) GetThemeFont(name string) Font.Instance

Returns a graphics.gd/classdb/Font from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a font item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) GetThemeFontSize

func (self Instance) GetThemeFontSize(name string) int

Returns a font size from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a font size item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) GetThemeIcon

func (self Instance) GetThemeIcon(name string) Texture2D.Instance

Returns an icon from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has an icon item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) GetThemeStylebox

func (self Instance) GetThemeStylebox(name string) StyleBox.Instance

Returns a graphics.gd/classdb/StyleBox from the first matching graphics.gd/classdb/Theme in the tree if that graphics.gd/classdb/Theme has a stylebox item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) GetTooltip

func (self Instance) GetTooltip() string

Returns the tooltip text for the position 'at_position' in control's local coordinates, which will typically appear when the cursor is resting over this control. By default, it returns Instance.TooltipText.

This method can be overridden to customize its behavior. See [Interface.GetTooltip].

Note: If this method returns an empty string and [Interface.MakeCustomTooltip] is not overridden, no tooltip is displayed.

func (Instance) GlobalPosition

func (self Instance) GlobalPosition() Vector2.XY

func (Instance) GrabClickFocus

func (self Instance) GrabClickFocus()

Creates an graphics.gd/classdb/InputEventMouseButton that attempts to click the control. If the event is received, the control gains focus.

control.GrabClickFocus() // When clicking another Control node, this node will be clicked instead.

func (Instance) GrabFocus

func (self Instance) GrabFocus()

Steal the focus from another control and become the focused control (see Instance.FocusMode).

Note: Using this method together with graphics.gd/classdb/Callable.Instance.CallDeferred makes it more reliable, especially when called inside graphics.gd/classdb/Node.Instance.Ready.

func (Instance) GrowHorizontal

func (self Instance) GrowHorizontal() GrowDirection

func (Instance) GrowVertical

func (self Instance) GrowVertical() GrowDirection

func (Instance) HasFocus

func (self Instance) HasFocus() bool

Returns true if this is the current focused control. See Instance.FocusMode.

func (Instance) HasThemeColor

func (self Instance) HasThemeColor(name string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has a color item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) HasThemeColorOverride

func (self Instance) HasThemeColorOverride(name string) bool

Returns true if there is a local override for a theme [Color.RGBA] with the specified 'name' in this graphics.gd/classdb/Control node.

See Instance.AddThemeColorOverride.

func (Instance) HasThemeConstant

func (self Instance) HasThemeConstant(name string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has a constant item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) HasThemeConstantOverride

func (self Instance) HasThemeConstantOverride(name string) bool

Returns true if there is a local override for a theme constant with the specified 'name' in this graphics.gd/classdb/Control node.

See Instance.AddThemeConstantOverride.

func (Instance) HasThemeFont

func (self Instance) HasThemeFont(name string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has a font item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) HasThemeFontOverride

func (self Instance) HasThemeFontOverride(name string) bool

Returns true if there is a local override for a theme graphics.gd/classdb/Font with the specified 'name' in this graphics.gd/classdb/Control node.

See Instance.AddThemeFontOverride.

func (Instance) HasThemeFontSize

func (self Instance) HasThemeFontSize(name string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has a font size item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) HasThemeFontSizeOverride

func (self Instance) HasThemeFontSizeOverride(name string) bool

Returns true if there is a local override for a theme font size with the specified 'name' in this graphics.gd/classdb/Control node.

See Instance.AddThemeFontSizeOverride.

func (Instance) HasThemeIcon

func (self Instance) HasThemeIcon(name string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has an icon item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) HasThemeIconOverride

func (self Instance) HasThemeIconOverride(name string) bool

Returns true if there is a local override for a theme icon with the specified 'name' in this graphics.gd/classdb/Control node.

See Instance.AddThemeIconOverride.

func (Instance) HasThemeStylebox

func (self Instance) HasThemeStylebox(name string) bool

Returns true if there is a matching graphics.gd/classdb/Theme in the tree that has a stylebox item with the specified 'name' and 'theme_type'.

See Instance.GetThemeColor for details.

func (Instance) HasThemeStyleboxOverride

func (self Instance) HasThemeStyleboxOverride(name string) bool

Returns true if there is a local override for a theme graphics.gd/classdb/StyleBox with the specified 'name' in this graphics.gd/classdb/Control node.

See Instance.AddThemeStyleboxOverride.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsDragSuccessful

func (self Instance) IsDragSuccessful() bool

Returns true if a drag operation is successful. Alternative to graphics.gd/classdb/Viewport.Instance.GuiIsDragSuccessful.

Best used with [Node.NotificationDragEnd].

func (Instance) IsLayoutRtl

func (self Instance) IsLayoutRtl() bool

Returns true if layout is right-to-left. See also Instance.LayoutDirection.

func (Instance) LayoutDirection

func (self Instance) LayoutDirection() LayoutDirection

func (Instance) LocalizeNumeralSystem

func (self Instance) LocalizeNumeralSystem() bool

func (Instance) MouseDefaultCursorShape

func (self Instance) MouseDefaultCursorShape() CursorShape

func (Instance) MouseFilter

func (self Instance) MouseFilter() MouseFilter

func (Instance) MouseForcePassScrollEvents

func (self Instance) MouseForcePassScrollEvents() bool

func (Instance) OffsetBottom

func (self Instance) OffsetBottom() Float.X

func (Instance) OffsetLeft

func (self Instance) OffsetLeft() Float.X

func (Instance) OffsetRight

func (self Instance) OffsetRight() Float.X

func (Instance) OffsetTop

func (self Instance) OffsetTop() Float.X

func (Instance) OnFocusEntered

func (self Instance) OnFocusEntered(cb func(), flags ...Signal.Flags)

func (Instance) OnFocusExited

func (self Instance) OnFocusExited(cb func(), flags ...Signal.Flags)

func (Instance) OnGuiInput

func (self Instance) OnGuiInput(cb func(event InputEvent.Instance), flags ...Signal.Flags)

func (Instance) OnMinimumSizeChanged

func (self Instance) OnMinimumSizeChanged(cb func(), flags ...Signal.Flags)

func (Instance) OnMouseEntered

func (self Instance) OnMouseEntered(cb func(), flags ...Signal.Flags)

func (Instance) OnMouseExited

func (self Instance) OnMouseExited(cb func(), flags ...Signal.Flags)

func (Instance) OnResized

func (self Instance) OnResized(cb func(), flags ...Signal.Flags)

func (Instance) OnSizeFlagsChanged

func (self Instance) OnSizeFlagsChanged(cb func(), flags ...Signal.Flags)

func (Instance) OnThemeChanged

func (self Instance) OnThemeChanged(cb func(), flags ...Signal.Flags)

func (Instance) PivotOffset

func (self Instance) PivotOffset() Vector2.XY

func (Instance) Position

func (self Instance) Position() Vector2.XY

func (Instance) ReleaseFocus

func (self Instance) ReleaseFocus()

Give up the focus. No other control will be able to receive input.

func (Instance) RemoveThemeColorOverride

func (self Instance) RemoveThemeColorOverride(name string)

Removes a local override for a theme [Color.RGBA] with the specified 'name' previously added by Instance.AddThemeColorOverride or via the Inspector dock.

func (Instance) RemoveThemeConstantOverride

func (self Instance) RemoveThemeConstantOverride(name string)

Removes a local override for a theme constant with the specified 'name' previously added by Instance.AddThemeConstantOverride or via the Inspector dock.

func (Instance) RemoveThemeFontOverride

func (self Instance) RemoveThemeFontOverride(name string)

Removes a local override for a theme graphics.gd/classdb/Font with the specified 'name' previously added by Instance.AddThemeFontOverride or via the Inspector dock.

func (Instance) RemoveThemeFontSizeOverride

func (self Instance) RemoveThemeFontSizeOverride(name string)

Removes a local override for a theme font size with the specified 'name' previously added by Instance.AddThemeFontSizeOverride or via the Inspector dock.

func (Instance) RemoveThemeIconOverride

func (self Instance) RemoveThemeIconOverride(name string)

Removes a local override for a theme icon with the specified 'name' previously added by Instance.AddThemeIconOverride or via the Inspector dock.

func (Instance) RemoveThemeStyleboxOverride

func (self Instance) RemoveThemeStyleboxOverride(name string)

Removes a local override for a theme graphics.gd/classdb/StyleBox with the specified 'name' previously added by Instance.AddThemeStyleboxOverride or via the Inspector dock.

func (Instance) ResetSize

func (self Instance) ResetSize()

Resets the size to Instance.GetCombinedMinimumSize. This is equivalent to calling set_size(Vector2()) (or any size below the minimum).

func (Instance) Rotation

func (self Instance) Rotation() Angle.Radians

func (Instance) RotationDegrees

func (self Instance) RotationDegrees() Angle.Radians

func (Instance) Scale

func (self Instance) Scale() Vector2.XY

func (Instance) SetAnchor

func (self Instance) SetAnchor(side Rect2.Side, anchor Float.X)

Sets the anchor for the specified [Side] to 'anchor'. A setter method for Instance.AnchorBottom, Instance.AnchorLeft, Instance.AnchorRight and Instance.AnchorTop.

If 'keep_offset' is true, offsets 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.

func (Instance) SetAnchorAndOffset

func (self Instance) SetAnchorAndOffset(side Rect2.Side, anchor Float.X, offset Float.X)

Works the same as Instance.SetAnchor, but instead of keep_offset argument and automatic update of offset, it allows to set the offset yourself (see [Instance.SetOffset]).

func (Instance) SetAnchorsAndOffsetsPreset

func (self Instance) SetAnchorsAndOffsetsPreset(preset LayoutPreset)

Sets both anchor preset and offset preset. See Instance.SetAnchorsPreset and Instance.SetOffsetsPreset.

func (Instance) SetAnchorsPreset

func (self Instance) SetAnchorsPreset(preset LayoutPreset)

Sets the anchors to a 'preset' from [Control.LayoutPreset] enum. This is the code equivalent to using the Layout menu in the 2D editor.

If 'keep_offsets' is true, control's position will also be updated.

func (Instance) SetAutoTranslate

func (self Instance) SetAutoTranslate(value bool)

func (Instance) SetBegin

func (self Instance) SetBegin(position Vector2.XY)

Sets Instance.OffsetLeft and Instance.OffsetTop at the same time. Equivalent of changing Instance.Position.

func (Instance) SetClipContents

func (self Instance) SetClipContents(value bool)

func (Instance) SetCustomMinimumSize

func (self Instance) SetCustomMinimumSize(value Vector2.XY)

func (Instance) SetDragForwarding

func (self Instance) SetDragForwarding(drag_func func(at_position Vector2.XY) any, can_drop_func func(at_position Vector2.XY, data any) bool, drop_func func(at_position Vector2.XY, data any))

Sets the given callables to be used instead of the control's own drag-and-drop virtual methods. If a callable is empty, its respective virtual method is used as normal.

The arguments for each callable should be exactly the same as their respective virtual methods, which would be:

- 'drag_func' corresponds to [Interface.GetDragData] and requires a [Vector2.XY];

- 'can_drop_func' corresponds to [Interface.CanDropData] and requires both a [Vector2.XY] and a any;

- 'drop_func' corresponds to [Interface.DropData] and requires both a [Vector2.XY] and a any.

func (Instance) SetDragPreview

func (self Instance) SetDragPreview(control Instance)

Shows the given control at the mouse pointer. A good time to call this method is in [Interface.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.

GetDragData := func(position Vector2.XY) any {
	// Use a control that is not in the tree
	var cpb = ColorPickerButton.New()
	cpb.SetColor(Color.RGBA{1, 0, 0, 1})
	cpb.AsControl().SetSize(Vector2.XY{50, 50})
	control.SetDragPreview(cpb.AsControl())
	return cpb.Color()

func (Instance) SetEnd

func (self Instance) SetEnd(position Vector2.XY)

Sets Instance.OffsetRight and Instance.OffsetBottom at the same time.

func (Instance) SetFocusMode

func (self Instance) SetFocusMode(value FocusMode)

func (Instance) SetFocusNeighborBottom

func (self Instance) SetFocusNeighborBottom(value string)

func (Instance) SetFocusNeighborLeft

func (self Instance) SetFocusNeighborLeft(value string)

func (Instance) SetFocusNeighborRight

func (self Instance) SetFocusNeighborRight(value string)

func (Instance) SetFocusNeighborTop

func (self Instance) SetFocusNeighborTop(value string)

func (Instance) SetFocusNext

func (self Instance) SetFocusNext(value string)

func (Instance) SetFocusPrevious

func (self Instance) SetFocusPrevious(value string)

func (Instance) SetGlobalPosition

func (self Instance) SetGlobalPosition(position Vector2.XY)

Sets the Instance.GlobalPosition to given 'position'.

If 'keep_offsets' is true, control's anchors will be updated instead of offsets.

func (Instance) SetGrowHorizontal

func (self Instance) SetGrowHorizontal(value GrowDirection)

func (Instance) SetGrowVertical

func (self Instance) SetGrowVertical(value GrowDirection)

func (Instance) SetLayoutDirection

func (self Instance) SetLayoutDirection(value LayoutDirection)

func (Instance) SetLocalizeNumeralSystem

func (self Instance) SetLocalizeNumeralSystem(value bool)

func (Instance) SetMouseDefaultCursorShape

func (self Instance) SetMouseDefaultCursorShape(value CursorShape)

func (Instance) SetMouseFilter

func (self Instance) SetMouseFilter(value MouseFilter)

func (Instance) SetMouseForcePassScrollEvents

func (self Instance) SetMouseForcePassScrollEvents(value bool)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetOffsetBottom

func (self Instance) SetOffsetBottom(value Float.X)

func (Instance) SetOffsetLeft

func (self Instance) SetOffsetLeft(value Float.X)

func (Instance) SetOffsetRight

func (self Instance) SetOffsetRight(value Float.X)

func (Instance) SetOffsetTop

func (self Instance) SetOffsetTop(value Float.X)

func (Instance) SetOffsetsPreset

func (self Instance) SetOffsetsPreset(preset LayoutPreset)

Sets the offsets to a 'preset' from [Control.LayoutPreset] enum. This is the code equivalent to using the Layout menu in the 2D editor.

Use parameter 'resize_mode' with constants from [Control.LayoutPresetMode] to better determine the resulting size of the graphics.gd/classdb/Control. Constant size will be ignored if used with presets that change size, e.g. PresetLeftWide.

Use parameter 'margin' to determine the gap between the graphics.gd/classdb/Control and the edges.

func (Instance) SetPivotOffset

func (self Instance) SetPivotOffset(value Vector2.XY)

func (Instance) SetPosition

func (self Instance) SetPosition(position Vector2.XY)

Sets the Instance.Position to given 'position'.

If 'keep_offsets' is true, control's anchors will be updated instead of offsets.

func (Instance) SetRotation

func (self Instance) SetRotation(value Angle.Radians)

func (Instance) SetRotationDegrees

func (self Instance) SetRotationDegrees(value Angle.Radians)

func (Instance) SetScale

func (self Instance) SetScale(value Vector2.XY)

func (Instance) SetShortcutContext

func (self Instance) SetShortcutContext(value Node.Instance)

func (Instance) SetSize

func (self Instance) SetSize(size Vector2.XY)

Sets the size (see Instance.Size).

If 'keep_offsets' is true, control's anchors will be updated instead of offsets.

func (Instance) SetSizeFlagsHorizontal

func (self Instance) SetSizeFlagsHorizontal(value SizeFlags)

func (Instance) SetSizeFlagsStretchRatio

func (self Instance) SetSizeFlagsStretchRatio(value Float.X)

func (Instance) SetSizeFlagsVertical

func (self Instance) SetSizeFlagsVertical(value SizeFlags)

func (Instance) SetTheme

func (self Instance) SetTheme(value Theme.Instance)

func (Instance) SetThemeTypeVariation

func (self Instance) SetThemeTypeVariation(value string)

func (Instance) SetTooltipAutoTranslateMode

func (self Instance) SetTooltipAutoTranslateMode(value Node.AutoTranslateMode)

func (Instance) SetTooltipText

func (self Instance) SetTooltipText(value string)

func (Instance) ShortcutContext

func (self Instance) ShortcutContext() Node.Instance

func (Instance) Size

func (self Instance) Size() Vector2.XY

func (Instance) SizeFlagsHorizontal

func (self Instance) SizeFlagsHorizontal() SizeFlags

func (Instance) SizeFlagsStretchRatio

func (self Instance) SizeFlagsStretchRatio() Float.X

func (Instance) SizeFlagsVertical

func (self Instance) SizeFlagsVertical() SizeFlags

func (Instance) Theme

func (self Instance) Theme() Theme.Instance

func (Instance) ThemeTypeVariation

func (self Instance) ThemeTypeVariation() string

func (Instance) TooltipAutoTranslateMode

func (self Instance) TooltipAutoTranslateMode() Node.AutoTranslateMode

func (Instance) TooltipText

func (self Instance) TooltipText() string

func (Instance) UpdateMinimumSize

func (self Instance) UpdateMinimumSize()

Invalidates the size cache in this node and in parent nodes up to top level. Intended to be used with Instance.GetMinimumSize when the return value is changed. Setting Instance.CustomMinimumSize directly calls this method automatically.

func (Instance) Virtual

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

func (Instance) WarpMouse

func (self Instance) WarpMouse(position Vector2.XY)

Moves the mouse cursor to 'position', relative to Instance.Position of this graphics.gd/classdb/Control.

Note: Instance.WarpMouse is only supported on Windows, macOS and Linux. It has no effect on Android, iOS and Web.

type Interface

type Interface interface {
	// 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 Rect2(Vector2.ZERO, size).has_point(point).
	HasPoint(point Vector2.XY) bool
	// User defined BiDi algorithm override function.
	//
	// Returns an slice of [Vector3i.XYZ] text ranges and text base directions, in the left-to-right order. Ranges should cover full source 'text' without overlaps. BiDi algorithm will be used on each range separately.
	StructuredTextParser(args []any, text string) []Vector3i.XYZ
	// Virtual method to be implemented by the user. Returns the minimum size for this control. Alternative to [Instance.CustomMinimumSize] 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].
	//
	// Note: This method will not be called when the script is attached to a [graphics.gd/classdb/Control] node that already overrides its minimum size (e.g. [graphics.gd/classdb/Label], [graphics.gd/classdb/Button], [graphics.gd/classdb/PanelContainer] etc.). It can only be used with most basic GUI nodes, like [graphics.gd/classdb/Control], [graphics.gd/classdb/Container], [graphics.gd/classdb/Panel] etc.
	GetMinimumSize() Vector2.XY
	// Virtual method to be implemented by the user. Returns the tooltip text for the position 'at_position' in control's local coordinates, which will typically appear when the cursor is resting over this control. See [Instance.GetTooltip].
	//
	// Note: If this method returns an empty string and [Interface.MakeCustomTooltip] is not overridden, no tooltip is displayed.
	GetTooltip(at_position Vector2.XY) string
	// 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 [Interface.CanDropData] and [Interface.DropData]. 'at_position' is local to this control. Drag may be forced with [Instance.ForceDrag].
	//
	// A preview that will follow the mouse that should represent the data can be set with [Instance.SetDragPreview]. A good time to set the preview is in this method.
	//
	//
	//
	// [gdscript]
	//
	// func _get_drag_data(position):
	//
	//     var mydata = make_data() # This is your custom method generating the drag data.
	//
	//     set_drag_preview(make_preview(mydata)) # This is your custom method generating the preview of the drag data.
	//
	//     return mydata
	//
	// [/gdscript]
	//
	// [csharp]
	//
	// public override Variant _GetDragData(Vector2 atPosition)
	//
	// {
	//
	//     var myData = MakeData(); // This is your custom method generating the drag data.
	//
	//     SetDragPreview(MakePreview(myData)); // This is your custom method generating the preview of the drag data.
	//
	//     return myData;
	//
	// }
	//
	// [/csharp]
	//
	//
	GetDragData(at_position Vector2.XY) any
	// Godot calls this method to test if 'data' from a control's [Interface.GetDragData] can be dropped at 'at_position'. 'at_position' is local to this control.
	//
	// This method should only be used to test the data. Process the data in [Interface.DropData].
	//
	//
	//
	// [gdscript]
	//
	// 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")
	//
	// [/gdscript]
	//
	// [csharp]
	//
	// public override bool _CanDropData(Vector2 atPosition, Variant data)
	//
	// {
	//
	//     // Check position if it is relevant to you
	//
	//     // Otherwise, just check data
	//
	//     return data.VariantType == Variant.Type.Dictionary && data.AsGodotDictionary().ContainsKey("expected");
	//
	// }
	//
	// [/csharp]
	//
	//
	CanDropData(at_position Vector2.XY, data any) bool
	// Godot calls this method to pass you the 'data' from a control's [Interface.GetDragData] result. Godot first calls [Interface.CanDropData] to test if 'data' is allowed to drop at 'at_position' where 'at_position' is local to this control.
	//
	//
	//
	// [gdscript]
	//
	// func _can_drop_data(position, data):
	//
	//     return typeof(data) == TYPE_DICTIONARY and data.has("color")
	//
	//
	//
	// func _drop_data(position, data):
	//
	//     var color = data["color"]
	//
	// [/gdscript]
	//
	// [csharp]
	//
	// public override bool _CanDropData(Vector2 atPosition, Variant data)
	//
	// {
	//
	//     return data.VariantType == Variant.Type.Dictionary && data.AsGodotDictionary().ContainsKey("color");
	//
	// }
	//
	//
	//
	// public override void _DropData(Vector2 atPosition, Variant data)
	//
	// {
	//
	//     Color color = data.AsGodotDictionary()["color"].AsColor();
	//
	// }
	//
	// [/csharp]
	//
	//
	DropData(at_position Vector2.XY, data any)
	// Virtual method to be implemented by the user. Returns a [graphics.gd/classdb/Control] node that should be used as a tooltip instead of the default one. 'for_text' is the return value of [Instance.GetTooltip].
	//
	// The returned node must be of type [graphics.gd/classdb/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 [graphics.gd/classdb/PopupPanel], so you should only provide the contents of that panel. That [graphics.gd/classdb/PopupPanel] can be themed using [graphics.gd/classdb/Theme.Instance.SetStylebox] for the type "TooltipPanel" (see [Instance.TooltipText] 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 [Instance.CustomMinimumSize] to some non-zero value.
	//
	// Note: The node (and any relevant children) should have their [graphics.gd/classdb/CanvasItem.Instance.Visible] set to true when returned, otherwise, the viewport that instantiates it will not be able to calculate its minimum size reliably.
	//
	// Note: If overridden, this method is called even if [Instance.GetTooltip] returns an empty string. When this happens with the default tooltip, it is not displayed. To copy this behavior, return null in this method when 'for_text' is empty.
	//
	// Example: Use a constructed node as a tooltip:
	//
	//
	//
	// [gdscript]
	//
	// func _make_custom_tooltip(for_text):
	//
	//     var label = Label.new()
	//
	//     label.text = for_text
	//
	//     return label
	//
	// [/gdscript]
	//
	// [csharp]
	//
	// public override Control _MakeCustomTooltip(string forText)
	//
	// {
	//
	//     var label = new Label();
	//
	//     label.Text = forText;
	//
	//     return label;
	//
	// }
	//
	// [/csharp]
	//
	//
	//
	// Example: Usa a scene instance as a tooltip:
	//
	//
	//
	// [gdscript]
	//
	// func _make_custom_tooltip(for_text):
	//
	//     var tooltip = preload("res://some_tooltip_scene.tscn").instantiate()
	//
	//     tooltip.get_node("Label").text = for_text
	//
	//     return tooltip
	//
	// [/gdscript]
	//
	// [csharp]
	//
	// public override Control _MakeCustomTooltip(string forText)
	//
	// {
	//
	//     Node tooltip = ResourceLoader.Load<PackedScene>("res://some_tooltip_scene.tscn").Instantiate();
	//
	//     tooltip.GetNode<Label>("Label").Text = forText;
	//
	//     return tooltip;
	//
	// }
	//
	// [/csharp]
	//
	//
	MakeCustomTooltip(for_text string) Object.Instance
	// Virtual method to be implemented by the user. Override this method to handle and accept inputs on UI elements. See also [Instance.AcceptEvent].
	//
	// Example: Click on the control to print a message:
	//
	//
	//
	// [gdscript]
	//
	// func _gui_input(event):
	//
	//     if event is InputEventMouseButton:
	//
	//         if event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
	//
	//             print("I've been clicked D:")
	//
	// [/gdscript]
	//
	// [csharp]
	//
	// public override void _GuiInput(InputEvent @event)
	//
	// {
	//
	//     if (@event is InputEventMouseButton mb)
	//
	//     {
	//
	//         if (mb.ButtonIndex == MouseButton.Left && mb.Pressed)
	//
	//         {
	//
	//             GD.Print("I've been clicked D:");
	//
	//         }
	//
	//     }
	//
	// }
	//
	// [/csharp]
	//
	//
	//
	// If the 'event' inherits [graphics.gd/classdb/InputEventMouse], this method will not be called when:
	//
	// - the control's [Instance.MouseFilter] is set to [MouseFilterIgnore];
	//
	// - the control is obstructed by another control on top, that doesn't have [Instance.MouseFilter] set to [MouseFilterIgnore];
	//
	// - the control's parent has [Instance.MouseFilter] set to [MouseFilterStop] or has accepted the event;
	//
	// - the control's parent has [Instance.ClipContents] enabled and the 'event”s position is outside the parent's rectangle;
	//
	// - the 'event”s position is outside the control (see [Interface.HasPoint]).
	//
	// Note: The 'event”s position is relative to this control's origin.
	GuiInput(event InputEvent.Instance)
}

type LayoutDirection

type LayoutDirection int //gd:Control.LayoutDirection
const (
	// Automatic layout direction, determined from the parent control layout direction.
	LayoutDirectionInherited LayoutDirection = 0
	// Automatic layout direction, determined from the current locale. Right-to-left layout direction is automatically used for languages that require it such as Arabic and Hebrew, but only if a valid translation file is loaded for the given language (unless said language is configured as a fallback in [graphics.gd/classdb/ProjectSettings] "internationalization/locale/fallback"). For all other languages (or if no valid translation file is found by Godot), left-to-right layout direction is used. If using [graphics.gd/classdb/TextServerFallback] ([graphics.gd/classdb/ProjectSettings] "internationalization/rendering/text_driver"), left-to-right layout direction is always used regardless of the language. Right-to-left layout direction can also be forced using [graphics.gd/classdb/ProjectSettings] "internationalization/rendering/force_right_to_left_layout_direction".
	LayoutDirectionApplicationLocale LayoutDirection = 1
	// Left-to-right layout direction.
	LayoutDirectionLtr LayoutDirection = 2
	// Right-to-left layout direction.
	LayoutDirectionRtl LayoutDirection = 3
	// Automatic layout direction, determined from the system locale. Right-to-left layout direction is automatically used for languages that require it such as Arabic and Hebrew, but only if a valid translation file is loaded for the given language.. For all other languages (or if no valid translation file is found by Godot), left-to-right layout direction is used. If using [graphics.gd/classdb/TextServerFallback] ([graphics.gd/classdb/ProjectSettings] "internationalization/rendering/text_driver"), left-to-right layout direction is always used regardless of the language.
	LayoutDirectionSystemLocale LayoutDirection = 4
	// Represents the size of the [LayoutDirection] enum.
	LayoutDirectionMax    LayoutDirection = 5
	LayoutDirectionLocale LayoutDirection = 1
)

type LayoutPreset

type LayoutPreset int //gd:Control.LayoutPreset
const (
	// Snap all 4 anchors to the top-left of the parent control's bounds. Use with [Instance.SetAnchorsPreset].
	PresetTopLeft LayoutPreset = 0
	// Snap all 4 anchors to the top-right of the parent control's bounds. Use with [Instance.SetAnchorsPreset].
	PresetTopRight LayoutPreset = 1
	// Snap all 4 anchors to the bottom-left of the parent control's bounds. Use with [Instance.SetAnchorsPreset].
	PresetBottomLeft LayoutPreset = 2
	// Snap all 4 anchors to the bottom-right of the parent control's bounds. Use with [Instance.SetAnchorsPreset].
	PresetBottomRight LayoutPreset = 3
	// Snap all 4 anchors to the center of the left edge of the parent control's bounds. Use with [Instance.SetAnchorsPreset].
	PresetCenterLeft LayoutPreset = 4
	// Snap all 4 anchors to the center of the top edge of the parent control's bounds. Use with [Instance.SetAnchorsPreset].
	PresetCenterTop LayoutPreset = 5
	// Snap all 4 anchors to the center of the right edge of the parent control's bounds. Use with [Instance.SetAnchorsPreset].
	PresetCenterRight LayoutPreset = 6
	// Snap all 4 anchors to the center of the bottom edge of the parent control's bounds. Use with [Instance.SetAnchorsPreset].
	PresetCenterBottom LayoutPreset = 7
	// Snap all 4 anchors to the center of the parent control's bounds. Use with [Instance.SetAnchorsPreset].
	PresetCenter LayoutPreset = 8
	// Snap all 4 anchors to the left edge of the parent control. The left offset becomes relative to the left edge and the top offset relative to the top left corner of the node's parent. Use with [Instance.SetAnchorsPreset].
	PresetLeftWide LayoutPreset = 9
	// Snap all 4 anchors to the top edge of the parent control. The left offset becomes relative to the top left corner, the top offset relative to the top edge, and the right offset relative to the top right corner of the node's parent. Use with [Instance.SetAnchorsPreset].
	PresetTopWide LayoutPreset = 10
	// Snap all 4 anchors to the right edge of the parent control. The right offset becomes relative to the right edge and the top offset relative to the top right corner of the node's parent. Use with [Instance.SetAnchorsPreset].
	PresetRightWide LayoutPreset = 11
	// Snap all 4 anchors to the bottom edge of the parent control. The left offset becomes relative to the bottom left corner, the bottom offset relative to the bottom edge, and the right offset relative to the bottom right corner of the node's parent. Use with [Instance.SetAnchorsPreset].
	PresetBottomWide LayoutPreset = 12
	// Snap all 4 anchors to a vertical line that cuts the parent control in half. Use with [Instance.SetAnchorsPreset].
	PresetVcenterWide LayoutPreset = 13
	// Snap all 4 anchors to a horizontal line that cuts the parent control in half. Use with [Instance.SetAnchorsPreset].
	PresetHcenterWide LayoutPreset = 14
	// Snap all 4 anchors to the respective corners of the parent control. Set all 4 offsets to 0 after you applied this preset and the [graphics.gd/classdb/Control] will fit its parent control. Use with [Instance.SetAnchorsPreset].
	PresetFullRect LayoutPreset = 15
)

type LayoutPresetMode

type LayoutPresetMode int //gd:Control.LayoutPresetMode
const (
	// The control will be resized to its minimum size.
	PresetModeMinsize LayoutPresetMode = 0
	// The control's width will not change.
	PresetModeKeepWidth LayoutPresetMode = 1
	// The control's height will not change.
	PresetModeKeepHeight LayoutPresetMode = 2
	// The control's size will not change.
	PresetModeKeepSize LayoutPresetMode = 3
)

type MouseFilter

type MouseFilter int //gd:Control.MouseFilter
const (
	// The control will receive mouse movement input events and mouse button input events if clicked on through [Instance.GuiInput]. The control will also receive the [Instance.OnMouseEntered] and [Instance.OnMouseExited] signals. These events are automatically marked as handled, and they will not propagate further to other controls. This also results in blocking signals in other controls.
	MouseFilterStop MouseFilter = 0
	// The control will receive mouse movement input events and mouse button input events if clicked on through [Instance.GuiInput]. The control will also receive the [Instance.OnMouseEntered] and [Instance.OnMouseExited] signals.
	//
	// If this control does not handle the event, the event will propagate up to its parent control if it has one. The event is bubbled up the node hierarchy until it reaches a non-[graphics.gd/classdb/CanvasItem], a control with [MouseFilterStop], or a [graphics.gd/classdb/CanvasItem] with [graphics.gd/classdb/CanvasItem.Instance.TopLevel] enabled. This will allow signals to fire in all controls it reaches. If no control handled it, the event will be passed to [graphics.gd/classdb/Node.Instance.ShortcutInput] for further processing.
	MouseFilterPass MouseFilter = 1
	// The control will not receive any mouse movement input events nor mouse button input events through [Instance.GuiInput]. The control will also not receive the [Instance.OnMouseEntered] nor [Instance.OnMouseExited] signals. This will not block other controls from receiving these events or firing the signals. Ignored events will not be handled automatically. If a child has [MouseFilterPass] and an event was passed to this control, the event will further propagate up to the control's parent.
	//
	// Note: If the control has received [Instance.OnMouseEntered] but not [Instance.OnMouseExited], changing the [Instance.MouseFilter] to [MouseFilterIgnore] will cause [Instance.OnMouseExited] to be emitted.
	MouseFilterIgnore MouseFilter = 2
)

type SizeFlags

type SizeFlags int //gd:Control.SizeFlags
const (
	// Tells the parent [graphics.gd/classdb/Container] to align the node with its start, either the top or the left edge. It is mutually exclusive with [SizeFill] and other shrink size flags, but can be used with [SizeExpand] in some containers. Use with [Instance.SizeFlagsHorizontal] and [Instance.SizeFlagsVertical].
	//
	// Note: Setting this flag is equal to not having any size flags.
	SizeShrinkBegin SizeFlags = 0
	// Tells the parent [graphics.gd/classdb/Container] to expand the bounds of this node to fill all the available space without pushing any other node. It is mutually exclusive with shrink size flags. Use with [Instance.SizeFlagsHorizontal] and [Instance.SizeFlagsVertical].
	SizeFill SizeFlags = 1
	// Tells the parent [graphics.gd/classdb/Container] to let this node take all the available space on the axis you flag. If multiple neighboring nodes are set to expand, they'll share the space based on their stretch ratio. See [Instance.SizeFlagsStretchRatio]. Use with [Instance.SizeFlagsHorizontal] and [Instance.SizeFlagsVertical].
	SizeExpand SizeFlags = 2
	// Sets the node's size flags to both fill and expand. See [SizeFill] and [SizeExpand] for more information.
	SizeExpandFill SizeFlags = 3
	// Tells the parent [graphics.gd/classdb/Container] to center the node in the available space. It is mutually exclusive with [SizeFill] and other shrink size flags, but can be used with [SizeExpand] in some containers. Use with [Instance.SizeFlagsHorizontal] and [Instance.SizeFlagsVertical].
	SizeShrinkCenter SizeFlags = 4
	// Tells the parent [graphics.gd/classdb/Container] to align the node with its end, either the bottom or the right edge. It is mutually exclusive with [SizeFill] and other shrink size flags, but can be used with [SizeExpand] in some containers. Use with [Instance.SizeFlagsHorizontal] and [Instance.SizeFlagsVertical].
	SizeShrinkEnd SizeFlags = 8
)

type TextDirection

type TextDirection int //gd:Control.TextDirection
const (
	// Text writing direction is the same as layout direction.
	TextDirectionInherited TextDirection = 3
	// Automatic text writing direction, determined from the current locale and text content.
	TextDirectionAuto TextDirection = 0
	// Left-to-right text writing direction.
	TextDirectionLtr TextDirection = 1
	// Right-to-left text writing direction.
	TextDirectionRtl TextDirection = 2
)

Jump to

Keyboard shortcuts

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