Documentation
¶
Overview ¶
Base class for all UI-related nodes. 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 Control and Container nodes.
Note: Since both Node2D and Control inherit from CanvasItem, they share several concepts from the class such as the CanvasItem.ZIndex and CanvasItem.Visible properties.
User Interface nodes and input ¶
Godot propagates input events via viewports. Each Viewport is responsible for propagating InputEvents to their child nodes. As the SceneTree.Root is a Window, this already happens automatically for all UI elements in your game.
Input events are propagated through the SceneTree from the root node to all child nodes by calling Node.Input. For UI elements specifically, it makes more sense to override the virtual method GuiInput, which filters out unrelated input events, such as by checking z-order, MouseFilter, focus, or if the event was inside of the control's bounding box.
Call AcceptEvent so no other node receives the event. Once you accept an input, it becomes handled so Node.UnhandledInput will not process it.
Only one Control node can be in focus. Only the node in focus will receive events. To get the focus, call GrabFocus. Control nodes lose focus when another node grabs it, or if you hide the node in focus.
Sets MouseFilter to MouseFilterIgnore to tell a Control node to ignore mouse or touch events. You'll need it if you place an icon on top of a button.
Theme resources change the control's appearance. The Theme of a 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 AddThemeFontOverride. You can also override theme items in the Inspector.
Note: Theme items are not Object properties. This means you can't access their values using Object.Get and Object.Set. Instead, use the get_theme_* and add_theme_*_override methods provided by this class.
Index ¶
- Constants
- type Advanced
- type Anchor
- type Any
- type CursorShape
- type Expanded
- type Extension
- type FocusBehaviorRecursive
- type FocusMode
- type GrowDirection
- type ID
- type Implementation
- type Instance
- func (self Instance) AcceptEvent()
- func (self Instance) AccessibilityControlsNodes() []string
- func (self Instance) AccessibilityDescribedByNodes() []string
- func (self Instance) AccessibilityDescription() string
- func (self Instance) AccessibilityDrag()
- func (self Instance) AccessibilityDrop()
- func (self Instance) AccessibilityFlowToNodes() []string
- func (self Instance) AccessibilityLabeledByNodes() []string
- func (self Instance) AccessibilityLive() DisplayServer.AccessibilityLiveMode
- func (self Instance) AccessibilityName() string
- func (self Instance) AddThemeColorOverride(name string, color Color.RGBA)
- func (self Instance) AddThemeConstantOverride(name string, constant int)
- func (self Instance) AddThemeFontOverride(name string, font Font.Instance)
- func (self Instance) AddThemeFontSizeOverride(name string, font_size int)
- func (self Instance) AddThemeIconOverride(name string, texture Texture2D.Instance)
- func (self Instance) AddThemeStyleboxOverride(name string, stylebox StyleBox.Instance)
- func (self Instance) AnchorBottom() Float.X
- func (self Instance) AnchorLeft() Float.X
- func (self Instance) AnchorRight() Float.X
- func (self Instance) AnchorTop() Float.X
- func (self Instance) AsCanvasItem() CanvasItem.Instance
- func (self Instance) AsControl() Instance
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AutoTranslate() bool
- func (self Instance) BeginBulkThemeOverride()
- func (self Instance) ClipContents() bool
- func (self Instance) CustomMinimumSize() Vector2.XY
- func (self Instance) EndBulkThemeOverride()
- func (self Instance) FindNextValidFocus() Instance
- func (self Instance) FindPrevValidFocus() Instance
- func (self Instance) FindValidFocusNeighbor(side Rect2.Side) Instance
- func (self Instance) FocusBehaviorRecursive() FocusBehaviorRecursive
- func (self Instance) FocusMode() FocusMode
- func (self Instance) FocusNeighborBottom() string
- func (self Instance) FocusNeighborLeft() string
- func (self Instance) FocusNeighborRight() string
- func (self Instance) FocusNeighborTop() string
- func (self Instance) FocusNext() string
- func (self Instance) FocusPrevious() string
- func (self Instance) ForceDrag(data any, preview Instance)
- func (self Instance) GetBegin() Vector2.XY
- func (self Instance) GetCombinedMinimumSize() Vector2.XY
- func (self Instance) GetCursorShape() CursorShape
- func (self Instance) GetEnd() Vector2.XY
- func (self Instance) GetFocusModeWithOverride() FocusMode
- func (self Instance) GetGlobalRect() Rect2.PositionSize
- func (self Instance) GetMinimumSize() Vector2.XY
- func (self Instance) GetMouseFilterWithOverride() MouseFilter
- func (self Instance) GetParentAreaSize() Vector2.XY
- func (self Instance) GetParentControl() Instance
- func (self Instance) GetRect() Rect2.PositionSize
- func (self Instance) GetScreenPosition() Vector2.XY
- func (self Instance) GetThemeColor(name string) Color.RGBA
- func (self Instance) GetThemeConstant(name string) int
- func (self Instance) GetThemeDefaultBaseScale() Float.X
- func (self Instance) GetThemeDefaultFont() Font.Instance
- func (self Instance) GetThemeDefaultFontSize() int
- func (self Instance) GetThemeFont(name string) Font.Instance
- func (self Instance) GetThemeFontSize(name string) int
- func (self Instance) GetThemeIcon(name string) Texture2D.Instance
- func (self Instance) GetThemeStylebox(name string) StyleBox.Instance
- func (self Instance) GetTooltip() string
- func (self Instance) GlobalPosition() Vector2.XY
- func (self Instance) GrabClickFocus()
- func (self Instance) GrabFocus()
- func (self Instance) GrowHorizontal() GrowDirection
- func (self Instance) GrowVertical() GrowDirection
- func (self Instance) HasFocus() bool
- func (self Instance) HasThemeColor(name string) bool
- func (self Instance) HasThemeColorOverride(name string) bool
- func (self Instance) HasThemeConstant(name string) bool
- func (self Instance) HasThemeConstantOverride(name string) bool
- func (self Instance) HasThemeFont(name string) bool
- func (self Instance) HasThemeFontOverride(name string) bool
- func (self Instance) HasThemeFontSize(name string) bool
- func (self Instance) HasThemeFontSizeOverride(name string) bool
- func (self Instance) HasThemeIcon(name string) bool
- func (self Instance) HasThemeIconOverride(name string) bool
- func (self Instance) HasThemeStylebox(name string) bool
- func (self Instance) HasThemeStyleboxOverride(name string) bool
- func (self Instance) ID() ID
- func (self Instance) IsDragSuccessful() bool
- func (self Instance) IsLayoutRtl() bool
- func (self Instance) LayoutDirection() LayoutDirection
- func (self Instance) LocalizeNumeralSystem() bool
- func (self Instance) MoreArgs() MoreArgs
- func (self Instance) MouseBehaviorRecursive() MouseBehaviorRecursive
- func (self Instance) MouseDefaultCursorShape() CursorShape
- func (self Instance) MouseFilter() MouseFilter
- func (self Instance) MouseForcePassScrollEvents() bool
- func (self Instance) OffsetBottom() Float.X
- func (self Instance) OffsetLeft() Float.X
- func (self Instance) OffsetRight() Float.X
- func (self Instance) OffsetTop() Float.X
- func (self Instance) OnFocusEntered(cb func(), flags ...Signal.Flags)
- func (self Instance) OnFocusExited(cb func(), flags ...Signal.Flags)
- func (self Instance) OnGuiInput(cb func(event InputEvent.Instance), flags ...Signal.Flags)
- func (self Instance) OnMinimumSizeChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) OnMouseEntered(cb func(), flags ...Signal.Flags)
- func (self Instance) OnMouseExited(cb func(), flags ...Signal.Flags)
- func (self Instance) OnResized(cb func(), flags ...Signal.Flags)
- func (self Instance) OnSizeFlagsChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) OnThemeChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) PivotOffset() Vector2.XY
- func (self Instance) Position() Vector2.XY
- func (self Instance) ReleaseFocus()
- func (self Instance) RemoveThemeColorOverride(name string)
- func (self Instance) RemoveThemeConstantOverride(name string)
- func (self Instance) RemoveThemeFontOverride(name string)
- func (self Instance) RemoveThemeFontSizeOverride(name string)
- func (self Instance) RemoveThemeIconOverride(name string)
- func (self Instance) RemoveThemeStyleboxOverride(name string)
- func (self Instance) ResetSize()
- func (self Instance) Rotation() Float.X
- func (self Instance) RotationDegrees() Float.X
- func (self Instance) Scale() Vector2.XY
- func (self Instance) SetAccessibilityControlsNodes(value []string)
- func (self Instance) SetAccessibilityDescribedByNodes(value []string)
- func (self Instance) SetAccessibilityDescription(value string)
- func (self Instance) SetAccessibilityFlowToNodes(value []string)
- func (self Instance) SetAccessibilityLabeledByNodes(value []string)
- func (self Instance) SetAccessibilityLive(value DisplayServer.AccessibilityLiveMode)
- func (self Instance) SetAccessibilityName(value string)
- func (self Instance) SetAnchor(side Rect2.Side, anchor Float.X)
- func (self Instance) SetAnchorAndOffset(side Rect2.Side, anchor Float.X, offset Float.X)
- func (self Instance) SetAnchorsAndOffsetsPreset(preset LayoutPreset)
- func (self Instance) SetAnchorsPreset(preset LayoutPreset)
- func (self Instance) SetAutoTranslate(value bool)
- func (self Instance) SetBegin(position Vector2.XY)
- func (self Instance) SetClipContents(value bool)
- func (self Instance) SetCustomMinimumSize(value Vector2.XY)
- func (self Instance) SetDragForwarding(drag_func func(at_position Vector2.XY) any, ...)
- func (self Instance) SetDragPreview(control Instance)
- func (self Instance) SetEnd(position Vector2.XY)
- func (self Instance) SetFocusBehaviorRecursive(value FocusBehaviorRecursive)
- func (self Instance) SetFocusMode(value FocusMode)
- func (self Instance) SetFocusNeighborBottom(value string)
- func (self Instance) SetFocusNeighborLeft(value string)
- func (self Instance) SetFocusNeighborRight(value string)
- func (self Instance) SetFocusNeighborTop(value string)
- func (self Instance) SetFocusNext(value string)
- func (self Instance) SetFocusPrevious(value string)
- func (self Instance) SetGlobalPosition(position Vector2.XY)
- func (self Instance) SetGrowHorizontal(value GrowDirection)
- func (self Instance) SetGrowVertical(value GrowDirection)
- func (self Instance) SetLayoutDirection(value LayoutDirection)
- func (self Instance) SetLocalizeNumeralSystem(value bool)
- func (self Instance) SetMouseBehaviorRecursive(value MouseBehaviorRecursive)
- func (self Instance) SetMouseDefaultCursorShape(value CursorShape)
- func (self Instance) SetMouseFilter(value MouseFilter)
- func (self Instance) SetMouseForcePassScrollEvents(value bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetOffsetBottom(value Float.X)
- func (self Instance) SetOffsetLeft(value Float.X)
- func (self Instance) SetOffsetRight(value Float.X)
- func (self Instance) SetOffsetTop(value Float.X)
- func (self Instance) SetOffsetsPreset(preset LayoutPreset)
- func (self Instance) SetPivotOffset(value Vector2.XY)
- func (self Instance) SetPosition(position Vector2.XY)
- func (self Instance) SetRotation(value Float.X)
- func (self Instance) SetRotationDegrees(value Float.X)
- func (self Instance) SetScale(value Vector2.XY)
- func (self Instance) SetShortcutContext(value Node.Instance)
- func (self Instance) SetSize(size Vector2.XY)
- func (self Instance) SetSizeFlagsHorizontal(value SizeFlags)
- func (self Instance) SetSizeFlagsStretchRatio(value Float.X)
- func (self Instance) SetSizeFlagsVertical(value SizeFlags)
- func (self Instance) SetTheme(value Theme.Instance)
- func (self Instance) SetThemeTypeVariation(value string)
- func (self Instance) SetTooltipAutoTranslateMode(value Node.AutoTranslateMode)
- func (self Instance) SetTooltipText(value string)
- func (self Instance) ShortcutContext() Node.Instance
- func (self Instance) Size() Vector2.XY
- func (self Instance) SizeFlagsHorizontal() SizeFlags
- func (self Instance) SizeFlagsStretchRatio() Float.X
- func (self Instance) SizeFlagsVertical() SizeFlags
- func (self Instance) Theme() Theme.Instance
- func (self Instance) ThemeTypeVariation() string
- func (self Instance) TooltipAutoTranslateMode() Node.AutoTranslateMode
- func (self Instance) TooltipText() string
- func (self Instance) UpdateMinimumSize()
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) WarpMouse(position Vector2.XY)
- type Interface
- type LayoutDirection
- type LayoutPreset
- type LayoutPresetMode
- type MoreArgs
- func (self MoreArgs) GetCursorShape(position Vector2.XY) CursorShape
- func (self MoreArgs) GetThemeColor(name string, theme_type string) Color.RGBA
- func (self MoreArgs) GetThemeConstant(name string, theme_type string) int
- func (self MoreArgs) GetThemeFont(name string, theme_type string) Font.Instance
- func (self MoreArgs) GetThemeFontSize(name string, theme_type string) int
- func (self MoreArgs) GetThemeIcon(name string, theme_type string) Texture2D.Instance
- func (self MoreArgs) GetThemeStylebox(name string, theme_type string) StyleBox.Instance
- func (self MoreArgs) GetTooltip(at_position Vector2.XY) string
- func (self MoreArgs) HasThemeColor(name string, theme_type string) bool
- func (self MoreArgs) HasThemeConstant(name string, theme_type string) bool
- func (self MoreArgs) HasThemeFont(name string, theme_type string) bool
- func (self MoreArgs) HasThemeFontSize(name string, theme_type string) bool
- func (self MoreArgs) HasThemeIcon(name string, theme_type string) bool
- func (self MoreArgs) HasThemeStylebox(name string, theme_type string) bool
- func (self MoreArgs) SetAnchor(side Rect2.Side, anchor Float.X, keep_offset bool, push_opposite_anchor bool)
- func (self MoreArgs) SetAnchorAndOffset(side Rect2.Side, anchor Float.X, offset Float.X, push_opposite_anchor bool)
- func (self MoreArgs) SetAnchorsAndOffsetsPreset(preset LayoutPreset, resize_mode LayoutPresetMode, margin int)
- func (self MoreArgs) SetAnchorsPreset(preset LayoutPreset, keep_offsets bool)
- func (self MoreArgs) SetGlobalPosition(position Vector2.XY, keep_offsets bool)
- func (self MoreArgs) SetOffsetsPreset(preset LayoutPreset, resize_mode LayoutPresetMode, margin int)
- func (self MoreArgs) SetPosition(position Vector2.XY, keep_offsets bool)
- func (self MoreArgs) SetSize(size Vector2.XY, keep_offsets bool)
- type MouseBehaviorRecursive
- type MouseFilter
- type SizeFlags
- type TextDirection
Constants ¶
const NotificationFocusEnter Object.Notification = 43 //gd:Control.NOTIFICATION_FOCUS_ENTER
const NotificationFocusExit Object.Notification = 44 //gd:Control.NOTIFICATION_FOCUS_EXIT
const NotificationLayoutDirectionChanged Object.Notification = 49 //gd:Control.NOTIFICATION_LAYOUT_DIRECTION_CHANGED
const NotificationMouseEnter Object.Notification = 41 //gd:Control.NOTIFICATION_MOUSE_ENTER
const NotificationMouseEnterSelf Object.Notification = 60 //gd:Control.NOTIFICATION_MOUSE_ENTER_SELF
const NotificationMouseExit Object.Notification = 42 //gd:Control.NOTIFICATION_MOUSE_EXIT
const NotificationMouseExitSelf Object.Notification = 61 //gd:Control.NOTIFICATION_MOUSE_EXIT_SELF
const NotificationResized Object.Notification = 40 //gd:Control.NOTIFICATION_RESIZED
const NotificationScrollBegin Object.Notification = 47 //gd:Control.NOTIFICATION_SCROLL_BEGIN
const NotificationScrollEnd Object.Notification = 48 //gd:Control.NOTIFICATION_SCROLL_END
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 [AnchorLeft]. To change all 4 anchors at once, use [SetAnchorsPreset]. // // [AnchorLeft]: https://pkg.go.dev/graphics.gd/classdb/#Instance.AnchorLeft // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#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 [AnchorLeft]. To change all 4 anchors at once, use [SetAnchorsPreset]. // // [AnchorLeft]: https://pkg.go.dev/graphics.gd/classdb/#Instance.AnchorLeft // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset AnchorEnd Anchor = 1 )
type CursorShape ¶
type CursorShape int //gd:Control.CursorShape
const ( // Show the system's arrow mouse cursor when the user hovers the node. Use with [MouseDefaultCursorShape]. // // [MouseDefaultCursorShape]: https://pkg.go.dev/graphics.gd/classdb/#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 Extension ¶
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
type FocusBehaviorRecursive ¶
type FocusBehaviorRecursive int //gd:Control.FocusBehaviorRecursive
const ( // Inherits the [FocusBehaviorRecursive] from the parent control. If there is no parent control, this is the same as [FocusBehaviorEnabled]. // // [FocusBehaviorRecursive]: https://pkg.go.dev/graphics.gd/classdb/#Instance.FocusBehaviorRecursive FocusBehaviorInherited FocusBehaviorRecursive = 0 // Prevents the control from getting focused. [GetFocusModeWithOverride] will return [FocusNone]. // // [GetFocusModeWithOverride]: https://pkg.go.dev/graphics.gd/classdb/#Instance.GetFocusModeWithOverride FocusBehaviorDisabled FocusBehaviorRecursive = 1 // Allows the control to be focused, depending on the [FocusMode]. This can be used to ignore the parent's [FocusBehaviorRecursive]. [GetFocusModeWithOverride] will return the [FocusMode]. // // [FocusBehaviorRecursive]: https://pkg.go.dev/graphics.gd/classdb/#Instance.FocusBehaviorRecursive // [FocusMode]: https://pkg.go.dev/graphics.gd/classdb/#Instance.FocusMode // [GetFocusModeWithOverride]: https://pkg.go.dev/graphics.gd/classdb/#Instance.GetFocusModeWithOverride FocusBehaviorEnabled FocusBehaviorRecursive = 2 )
type FocusMode ¶
type FocusMode int //gd:Control.FocusMode
const ( // The node cannot grab focus. Use with [FocusMode]. // // [FocusMode]: https://pkg.go.dev/graphics.gd/classdb/#Instance.FocusMode FocusNone FocusMode = 0 // The node can only grab focus on mouse clicks. Use with [FocusMode]. // // [FocusMode]: https://pkg.go.dev/graphics.gd/classdb/#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 [FocusMode]. // // [FocusMode]: https://pkg.go.dev/graphics.gd/classdb/#Instance.FocusMode FocusAll FocusMode = 2 // The node can grab focus only when screen reader is active. Use with [FocusMode]. // // [FocusMode]: https://pkg.go.dev/graphics.gd/classdb/#Instance.FocusMode FocusAccessibility FocusMode = 3 )
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 ¶
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.
type Implementation ¶
type Implementation = implementation
Implementation implements Interface with empty methods.
type Instance ¶
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 (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 Node.UnhandledInput or Node.UnhandledKeyInput.
Note: This does not affect the methods in Input, only the way events are propagated.
func (Instance) AccessibilityControlsNodes ¶
The paths to the nodes which are controlled by this node.
func (Instance) AccessibilityDescribedByNodes ¶
The paths to the nodes which are describing this node.
func (Instance) AccessibilityDescription ¶
The human-readable node description that is reported to assistive apps.
func (Instance) AccessibilityDrag ¶
func (self Instance) AccessibilityDrag()
Starts drag-and-drop operation without using a mouse.
func (Instance) AccessibilityDrop ¶
func (self Instance) AccessibilityDrop()
Ends drag-and-drop operation without using a mouse.
func (Instance) AccessibilityFlowToNodes ¶
The paths to the nodes which this node flows into.
func (Instance) AccessibilityLabeledByNodes ¶
The paths to the nodes which label this node.
func (Instance) AccessibilityLive ¶
func (self Instance) AccessibilityLive() DisplayServer.AccessibilityLiveMode
The mode with which a live region updates. A live region is a Node that is updated as a result of an external event when the user's focus may be elsewhere.
func (Instance) AccessibilityName ¶
The human-readable node name that is reported to assistive apps.
func (Instance) AddThemeColorOverride ¶
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 RemoveThemeColorOverride.
See also GetThemeColor.
Example: Override a 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", MyLabel.AsControl().MoreArgs().GetThemeColor("font_color", "Label"))
func (Instance) AddThemeConstantOverride ¶
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 RemoveThemeConstantOverride.
See also GetThemeConstant.
func (Instance) AddThemeFontOverride ¶
Creates a local override for a theme Font with the specified 'name'. Local overrides always take precedence when fetching theme items for the control. An override can be removed with RemoveThemeFontOverride.
See also GetThemeFont.
func (Instance) AddThemeFontSizeOverride ¶
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 RemoveThemeFontSizeOverride.
See also GetThemeFontSize.
func (Instance) AddThemeIconOverride ¶
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 RemoveThemeIconOverride.
See also GetThemeIcon.
func (Instance) AddThemeStyleboxOverride ¶
Creates a local override for a theme StyleBox with the specified 'name'. Local overrides always take precedence when fetching theme items for the control. An override can be removed with RemoveThemeStyleboxOverride.
See also GetThemeStylebox.
Example: Modify 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 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 ¶
Anchors the bottom edge of the node to the origin, the center, or the end of its parent control. It changes how the bottom offset updates when the node moves or changes size. You can use one of the Anchor constants for convenience.
func (Instance) AnchorLeft ¶
Anchors the left edge of the node to the origin, the center or the end of its parent control. It changes how the left offset updates when the node moves or changes size. You can use one of the Anchor constants for convenience.
func (Instance) AnchorRight ¶
Anchors the right edge of the node to the origin, the center or the end of its parent control. It changes how the right offset updates when the node moves or changes size. You can use one of the Anchor constants for convenience.
func (Instance) AnchorTop ¶
Anchors the top edge of the node to the origin, the center or the end of its parent control. It changes how the top offset updates when the node moves or changes size. You can use one of the Anchor constants for convenience.
func (Instance) AsCanvasItem ¶
func (self Instance) AsCanvasItem() CanvasItem.Instance
func (Instance) AutoTranslate ¶
Toggles if any text should automatically change to its translated version depending on the current locale.
func (Instance) BeginBulkThemeOverride ¶
func (self Instance) BeginBulkThemeOverride()
Prevents *_theme_*_override methods from emitting NotificationThemeChanged until EndBulkThemeOverride is called.
func (Instance) ClipContents ¶
Enables whether rendering of 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 and won't receive input.
func (Instance) CustomMinimumSize ¶
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. Note that Control nodes have their internal minimum size returned by GetMinimumSize. It depends on the control's contents, like text, textures, or style boxes. The actual minimum size is the maximum value of this property and the internal minimum size (see GetCombinedMinimumSize).
func (Instance) EndBulkThemeOverride ¶
func (self Instance) EndBulkThemeOverride()
Ends a bulk theme override update. See BeginBulkThemeOverride.
func (Instance) FindNextValidFocus ¶
Finds the next (below in the tree) Control that can receive the focus.
func (Instance) FindPrevValidFocus ¶
Finds the previous (above in the tree) Control that can receive the focus.
func (Instance) FindValidFocusNeighbor ¶
Finds the next Control that can receive the focus on the specified [Side].
Note: This is different from GetFocusNeighbor, which returns the path of a specified focus neighbor.
func (Instance) FocusBehaviorRecursive ¶
func (self Instance) FocusBehaviorRecursive() FocusBehaviorRecursive
Determines which controls can be focused together with FocusMode. See GetFocusModeWithOverride. Since the default behavior is FocusBehaviorInherited, this can be used to prevent all children controls from getting focused.
func (Instance) FocusMode ¶
Determines which controls can be focused. Only one control can be focused at a time, and the focused control will receive keyboard, gamepad, and mouse events in GuiInput. Use GetFocusModeWithOverride to determine if a control can grab focus, since FocusBehaviorRecursive also affects it. See also GrabFocus.
func (Instance) FocusNeighborBottom ¶
Tells Godot which node it should give 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 ProjectSettings "input/ui_down" input action. The node must be a Control. If this property is not set, Godot will give focus to the closest Control to the bottom of this one.
func (Instance) FocusNeighborLeft ¶
Tells Godot which node it should give 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 ProjectSettings "input/ui_left" input action. The node must be a Control. If this property is not set, Godot will give focus to the closest Control to the left of this one.
func (Instance) FocusNeighborRight ¶
Tells Godot which node it should give 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 ProjectSettings "input/ui_right" input action. The node must be a Control. If this property is not set, Godot will give focus to the closest Control to the right of this one.
func (Instance) FocusNeighborTop ¶
Tells Godot which node it should give 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 ProjectSettings "input/ui_up" input action. The node must be a Control. If this property is not set, Godot will give focus to the closest Control to the top of this one.
func (Instance) FocusNext ¶
Tells Godot which node it should give focus to if the user presses Tab on a keyboard by default. You can change the key by editing the ProjectSettings "input/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.
func (Instance) FocusPrevious ¶
Tells Godot which node it should give focus to if the user presses Shift + Tab on a keyboard by default. You can change the key by editing the ProjectSettings "input/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.
func (Instance) ForceDrag ¶
Forces drag and bypasses GetDragData and SetDragPreview by passing 'data' and 'preview'. Drag will start even if the mouse is neither over nor pressed on this control.
The methods CanDropData and DropData must be implemented on controls that want to receive drop data.
func (Instance) GetBegin ¶
Returns OffsetLeft and OffsetTop. See also Position.
func (Instance) GetCombinedMinimumSize ¶
Returns combined minimum size from CustomMinimumSize and GetMinimumSize.
func (Instance) GetCursorShape ¶
func (self Instance) GetCursorShape() CursorShape
Returns the mouse cursor shape for this control when hovered over 'position' in local coordinates. For most controls, this is the same as MouseDefaultCursorShape, but some built-in controls implement more complex logic.
func (Instance) GetEnd ¶
Returns OffsetRight and OffsetBottom.
func (Instance) GetFocusModeWithOverride ¶
Returns the FocusMode, but takes the FocusBehaviorRecursive into account. If FocusBehaviorRecursive is set to FocusBehaviorDisabled, or it is set to FocusBehaviorInherited and its ancestor is set to FocusBehaviorDisabled, then this returns FocusNone.
func (Instance) GetGlobalRect ¶
func (self Instance) GetGlobalRect() Rect2.PositionSize
Returns the position and size of the control relative to the containing canvas. See GlobalPosition and Size.
Note: If the node itself or any parent CanvasItem between the node and the canvas have a non default rotation or skew, the resulting size is likely not meaningful.
Note: Setting Viewport.GuiSnapControlsToPixels to true can lead to rounding inaccuracies between the displayed control and the returned Rect2.PositionSize.
func (Instance) GetMinimumSize ¶
Returns the minimum size for this control. See CustomMinimumSize.
func (Instance) GetMouseFilterWithOverride ¶
func (self Instance) GetMouseFilterWithOverride() MouseFilter
Returns the MouseFilter, but takes the MouseBehaviorRecursive into account. If MouseBehaviorRecursive is set to MouseBehaviorDisabled, or it is set to MouseBehaviorInherited and its ancestor is set to MouseBehaviorDisabled, then this returns MouseFilterIgnore.
func (Instance) GetParentAreaSize ¶
Returns the width/height occupied in the parent control.
func (Instance) GetParentControl ¶
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 Position, Scale and Size.
Note: If Rotation is not the default rotation, the resulting size is not meaningful.
Note: Setting Viewport.GuiSnapControlsToPixels to true can lead to rounding inaccuracies between the displayed control and the returned Rect2.PositionSize.
func (Instance) GetScreenPosition ¶
Returns the position of this Control in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
Equals to GlobalPosition if the window is embedded (see Viewport.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 ¶
Returns a Color.RGBA from the first matching Theme in the tree if that 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 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 AddThemeColorOverride), then its assigned Theme. After the current control, each parent control and its assigned Theme are considered; controls without a Theme assigned are skipped. If no matching Theme is found in the tree, the custom project Theme (see ProjectSettings "gui/theme/custom") and the default Theme are used (see 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.MoreArgs().GetThemeColor("font_color", "Button")
func (Instance) GetThemeConstant ¶
Returns a constant from the first matching Theme in the tree if that Theme has a constant item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) GetThemeDefaultBaseScale ¶
Returns the default base scale value from the first matching Theme in the tree if that Theme has a valid Theme.DefaultBaseScale value.
See GetThemeColor for details.
func (Instance) GetThemeDefaultFont ¶
Returns the default font from the first matching Theme in the tree if that Theme has a valid Theme.DefaultFont value.
See GetThemeColor for details.
func (Instance) GetThemeDefaultFontSize ¶
Returns the default font size value from the first matching Theme in the tree if that Theme has a valid Theme.DefaultFontSize value.
See GetThemeColor for details.
func (Instance) GetThemeFont ¶
Returns a Font from the first matching Theme in the tree if that Theme has a font item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) GetThemeFontSize ¶
Returns a font size from the first matching Theme in the tree if that Theme has a font size item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) GetThemeIcon ¶
Returns an icon from the first matching Theme in the tree if that Theme has an icon item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) GetThemeStylebox ¶
Returns a StyleBox from the first matching Theme in the tree if that Theme has a stylebox item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) GetTooltip ¶
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 TooltipText.
This method can be overridden to customize its behavior. See GetTooltip.
Note: If this method returns an empty string and MakeCustomTooltip is not overridden, no tooltip is displayed.
func (Instance) GlobalPosition ¶
The node's global position, relative to the world (usually to the CanvasLayer).
func (Instance) GrabClickFocus ¶
func (self Instance) GrabClickFocus()
Creates an 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 FocusMode).
Note: Using this method together with Callable.CallDeferred makes it more reliable, especially when called inside Node.Ready.
func (Instance) GrowHorizontal ¶
func (self Instance) GrowHorizontal() 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.
func (Instance) GrowVertical ¶
func (self Instance) GrowVertical() 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.
func (Instance) HasThemeColor ¶
Returns true if there is a matching Theme in the tree that has a color item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) HasThemeColorOverride ¶
Returns true if there is a local override for a theme Color.RGBA with the specified 'name' in this Control node.
func (Instance) HasThemeConstant ¶
Returns true if there is a matching Theme in the tree that has a constant item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) HasThemeConstantOverride ¶
Returns true if there is a local override for a theme constant with the specified 'name' in this Control node.
func (Instance) HasThemeFont ¶
Returns true if there is a matching Theme in the tree that has a font item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) HasThemeFontOverride ¶
Returns true if there is a local override for a theme Font with the specified 'name' in this Control node.
See AddThemeFontOverride.
func (Instance) HasThemeFontSize ¶
Returns true if there is a matching Theme in the tree that has a font size item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) HasThemeFontSizeOverride ¶
Returns true if there is a local override for a theme font size with the specified 'name' in this Control node.
func (Instance) HasThemeIcon ¶
Returns true if there is a matching Theme in the tree that has an icon item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) HasThemeIconOverride ¶
Returns true if there is a local override for a theme icon with the specified 'name' in this Control node.
See AddThemeIconOverride.
func (Instance) HasThemeStylebox ¶
Returns true if there is a matching Theme in the tree that has a stylebox item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (Instance) HasThemeStyleboxOverride ¶
Returns true if there is a local override for a theme StyleBox with the specified 'name' in this Control node.
func (Instance) IsDragSuccessful ¶
Returns true if a drag operation is successful. Alternative to Viewport.GuiIsDragSuccessful.
Best used with [Node.NotificationDragEnd].
func (Instance) IsLayoutRtl ¶
Returns true if the layout is right-to-left. See also LayoutDirection.
func (Instance) LayoutDirection ¶
func (self Instance) LayoutDirection() LayoutDirection
Controls layout direction and text writing direction. Right-to-left layouts are necessary for certain languages (e.g. Arabic and Hebrew). See also IsLayoutRtl.
func (Instance) LocalizeNumeralSystem ¶
If true, automatically converts code line numbers, list indices, SpinBox and ProgressBar values from the Western Arabic (0..9) to the numeral systems used in current locale.
Note: Numbers within the text are not automatically converted, it can be done manually, using TextServer.FormatNumber.
func (Instance) MoreArgs ¶
MoreArgs enables certain functions to be called with additional 'optional' arguments.
func (Instance) MouseBehaviorRecursive ¶
func (self Instance) MouseBehaviorRecursive() MouseBehaviorRecursive
Determines which controls can receive mouse input together with MouseFilter. See GetMouseFilterWithOverride. Since the default behavior is MouseBehaviorInherited, this can be used to prevent all children controls from receiving mouse input.
func (Instance) MouseDefaultCursorShape ¶
func (self Instance) MouseDefaultCursorShape() 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.
func (Instance) MouseFilter ¶
func (self Instance) MouseFilter() MouseFilter
Determines which controls will be able to receive mouse button input events through GuiInput and the OnMouseEntered, and OnMouseExited signals. Also determines how these events should be propagated. See the constants to learn what each does. Use GetMouseFilterWithOverride to determine if a control can receive mouse input, since MouseBehaviorRecursive also affects it.
func (Instance) MouseForcePassScrollEvents ¶
When enabled, scroll wheel events processed by GuiInput will be passed to the parent control even if MouseFilter is set to MouseFilterStop.
You should disable it on the root of your UI if you do not want scroll events to go to the Node.UnhandledInput processing.
Note: Because this property defaults to true, this allows nested scrollable containers to work out of the box.
func (Instance) OffsetBottom ¶
Distance between the node's bottom edge and its parent control, based on AnchorBottom.
Offsets are often controlled by one or multiple parent Container nodes, so you should not modify them manually if your node is a direct child of a Container. Offsets update automatically when you move or resize the node.
func (Instance) OffsetLeft ¶
Distance between the node's left edge and its parent control, based on AnchorLeft.
Offsets are often controlled by one or multiple parent Container nodes, so you should not modify them manually if your node is a direct child of a Container. Offsets update automatically when you move or resize the node.
func (Instance) OffsetRight ¶
Distance between the node's right edge and its parent control, based on AnchorRight.
Offsets are often controlled by one or multiple parent Container nodes, so you should not modify them manually if your node is a direct child of a Container. Offsets update automatically when you move or resize the node.
func (Instance) OffsetTop ¶
Distance between the node's top edge and its parent control, based on AnchorTop.
Offsets are often controlled by one or multiple parent Container nodes, so you should not modify them manually if your node is a direct child of a Container. Offsets update automatically when you move or resize the node.
func (Instance) OnFocusEntered ¶
Emitted when the node gains focus.
func (Instance) OnFocusExited ¶
Emitted when the node loses focus.
func (Instance) OnGuiInput ¶
func (self Instance) OnGuiInput(cb func(event InputEvent.Instance), flags ...Signal.Flags)
Emitted when the node receives an InputEvent.
func (Instance) OnMinimumSizeChanged ¶
Emitted when the node's minimum size changes.
func (Instance) OnMouseEntered ¶
Emitted when the mouse cursor enters the control's (or any child control's) visible area, that is not occluded behind other Controls or Windows, provided its MouseFilter lets the event reach it and regardless if it's currently focused or not.
Note: CanvasItem.ZIndex doesn't affect, which Control receives the signal.
func (Instance) OnMouseExited ¶
Emitted when the mouse cursor leaves the control's (and all child control's) visible area, that is not occluded behind other Controls or Windows, provided its MouseFilter lets the event reach it and regardless if it's currently focused or not.
Note: CanvasItem.ZIndex doesn't affect, which Control receives the signal.
Note: If you want to check whether the mouse truly left the area, ignoring any top nodes, you can use code like this:
func (Instance) OnSizeFlagsChanged ¶
Emitted when one of the size flags changes. See SizeFlagsHorizontal and SizeFlagsVertical.
func (Instance) OnThemeChanged ¶
Emitted when the NotificationThemeChanged notification is sent.
func (Instance) PivotOffset ¶
By default, the node's pivot is its top-left corner. When you change its Rotation or Scale, it will rotate or scale around this pivot. Set this property to Size / 2 to pivot around the Control's center.
func (Instance) Position ¶
The node's position, relative to its containing node. It corresponds to the rectangle's top-left corner. The property is not affected by PivotOffset.
func (Instance) ReleaseFocus ¶
func (self Instance) ReleaseFocus()
Give up the focus. No other control will be able to receive input.
func (Instance) RemoveThemeColorOverride ¶
Removes a local override for a theme Color.RGBA with the specified 'name' previously added by AddThemeColorOverride or via the Inspector dock.
func (Instance) RemoveThemeConstantOverride ¶
Removes a local override for a theme constant with the specified 'name' previously added by AddThemeConstantOverride or via the Inspector dock.
func (Instance) RemoveThemeFontOverride ¶
Removes a local override for a theme Font with the specified 'name' previously added by AddThemeFontOverride or via the Inspector dock.
func (Instance) RemoveThemeFontSizeOverride ¶
Removes a local override for a theme font size with the specified 'name' previously added by AddThemeFontSizeOverride or via the Inspector dock.
func (Instance) RemoveThemeIconOverride ¶
Removes a local override for a theme icon with the specified 'name' previously added by AddThemeIconOverride or via the Inspector dock.
func (Instance) RemoveThemeStyleboxOverride ¶
Removes a local override for a theme StyleBox with the specified 'name' previously added by AddThemeStyleboxOverride or via the Inspector dock.
func (Instance) ResetSize ¶
func (self Instance) ResetSize()
Resets the size to GetCombinedMinimumSize. This is equivalent to calling set_size(Vector2()) (or any size below the minimum).
func (Instance) Rotation ¶
The node's rotation around its pivot, in radians. See PivotOffset to change the pivot's position.
Note: This property is edited in the inspector in degrees. If you want to use degrees in a script, use RotationDegrees.
func (Instance) RotationDegrees ¶
Helper property to access Rotation in degrees instead of radians.
func (Instance) Scale ¶
The node's scale, relative to its Size. Change this property to scale the node around its PivotOffset. The Control's tooltip will also scale according to this value.
Note: This property is mainly intended to be used for animation purposes. To support multiple resolutions in your project, use an appropriate viewport stretch mode as described in the documentation instead of scaling Controls individually.
Note: FontFile.Oversampling does not take Control Scale into account. This means that scaling up/down will cause bitmap fonts and rasterized (non-MSDF) dynamic fonts to appear blurry or pixelated. To ensure text remains crisp regardless of scale, you can enable MSDF font rendering by enabling ProjectSettings "gui/theme/default_font_multichannel_signed_distance_field" (applies to the default project font only), or enabling Multichannel Signed Distance Field in the import options of a DynamicFont for custom fonts. On system fonts, SystemFont.MultichannelSignedDistanceField can be enabled in the inspector.
Note: If the Control node is a child of a Container node, the scale will be reset to Vector2(1, 1) when the scene is instantiated. To set the Control's scale when it's instantiated, wait for one frame using await get_tree().process_frame then set its Scale property.
func (Instance) SetAccessibilityControlsNodes ¶
SetAccessibilityControlsNodes sets the property returned by [GetAccessibilityControlsNodes].
func (Instance) SetAccessibilityDescribedByNodes ¶
SetAccessibilityDescribedByNodes sets the property returned by [GetAccessibilityDescribedByNodes].
func (Instance) SetAccessibilityDescription ¶
SetAccessibilityDescription sets the property returned by [GetAccessibilityDescription].
func (Instance) SetAccessibilityFlowToNodes ¶
SetAccessibilityFlowToNodes sets the property returned by [GetAccessibilityFlowToNodes].
func (Instance) SetAccessibilityLabeledByNodes ¶
SetAccessibilityLabeledByNodes sets the property returned by [GetAccessibilityLabeledByNodes].
func (Instance) SetAccessibilityLive ¶
func (self Instance) SetAccessibilityLive(value DisplayServer.AccessibilityLiveMode)
SetAccessibilityLive sets the property returned by [GetAccessibilityLive].
func (Instance) SetAccessibilityName ¶
SetAccessibilityName sets the property returned by [GetAccessibilityName].
func (Instance) SetAnchor ¶
Sets the anchor for the specified [Side] to 'anchor'. A setter method for AnchorBottom, AnchorLeft, AnchorRight and 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 ¶
Works the same as SetAnchor, but instead of keep_offset argument and automatic update of offset, it allows to set the offset yourself (see SetOffset).
func (Instance) SetAnchorsAndOffsetsPreset ¶
func (self Instance) SetAnchorsAndOffsetsPreset(preset LayoutPreset)
Sets both anchor preset and offset preset. See SetAnchorsPreset and 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 ¶
SetAutoTranslate sets the property returned by [IsAutoTranslating].
func (Instance) SetBegin ¶
Sets OffsetLeft and OffsetTop at the same time. Equivalent of changing Position.
func (Instance) SetClipContents ¶
SetClipContents sets the property returned by [IsClippingContents].
func (Instance) SetCustomMinimumSize ¶
SetCustomMinimumSize sets the property returned by [GetCustomMinimumSize].
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 GetDragData and requires a Vector2.XY;
- 'can_drop_func' corresponds to CanDropData and requires both a Vector2.XY and a any;
- 'drop_func' corresponds to DropData and requires both a Vector2.XY and a any.
func (Instance) SetDragPreview ¶
Shows the given control at the mouse pointer. A good time to call this method is in 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 ¶
Sets OffsetRight and OffsetBottom at the same time.
func (Instance) SetFocusBehaviorRecursive ¶
func (self Instance) SetFocusBehaviorRecursive(value FocusBehaviorRecursive)
SetFocusBehaviorRecursive sets the property returned by [GetFocusBehaviorRecursive].
func (Instance) SetFocusMode ¶
SetFocusMode sets the property returned by [GetFocusMode].
func (Instance) SetFocusNeighborBottom ¶
SetFocusNeighborBottom sets the property returned by [GetFocusNeighbor].
func (Instance) SetFocusNeighborLeft ¶
SetFocusNeighborLeft sets the property returned by [GetFocusNeighbor].
func (Instance) SetFocusNeighborRight ¶
SetFocusNeighborRight sets the property returned by [GetFocusNeighbor].
func (Instance) SetFocusNeighborTop ¶
SetFocusNeighborTop sets the property returned by [GetFocusNeighbor].
func (Instance) SetFocusNext ¶
SetFocusNext sets the property returned by [GetFocusNext].
func (Instance) SetFocusPrevious ¶
SetFocusPrevious sets the property returned by [GetFocusPrevious].
func (Instance) SetGlobalPosition ¶
Sets the 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)
SetGrowHorizontal sets the property returned by [GetHGrowDirection].
func (Instance) SetGrowVertical ¶
func (self Instance) SetGrowVertical(value GrowDirection)
SetGrowVertical sets the property returned by [GetVGrowDirection].
func (Instance) SetLayoutDirection ¶
func (self Instance) SetLayoutDirection(value LayoutDirection)
SetLayoutDirection sets the property returned by [GetLayoutDirection].
func (Instance) SetLocalizeNumeralSystem ¶
SetLocalizeNumeralSystem sets the property returned by [IsLocalizingNumeralSystem].
func (Instance) SetMouseBehaviorRecursive ¶
func (self Instance) SetMouseBehaviorRecursive(value MouseBehaviorRecursive)
SetMouseBehaviorRecursive sets the property returned by [GetMouseBehaviorRecursive].
func (Instance) SetMouseDefaultCursorShape ¶
func (self Instance) SetMouseDefaultCursorShape(value CursorShape)
SetMouseDefaultCursorShape sets the property returned by [GetDefaultCursorShape].
func (Instance) SetMouseFilter ¶
func (self Instance) SetMouseFilter(value MouseFilter)
SetMouseFilter sets the property returned by [GetMouseFilter].
func (Instance) SetMouseForcePassScrollEvents ¶
SetMouseForcePassScrollEvents sets the property returned by [IsForcePassScrollEvents].
func (Instance) SetOffsetBottom ¶
SetOffsetBottom sets the property returned by [GetOffset].
func (Instance) SetOffsetLeft ¶
SetOffsetLeft sets the property returned by [GetOffset].
func (Instance) SetOffsetRight ¶
SetOffsetRight sets the property returned by [GetOffset].
func (Instance) SetOffsetTop ¶
SetOffsetTop sets the property returned by [GetOffset].
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 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 Control and the edges.
func (Instance) SetPivotOffset ¶
SetPivotOffset sets the property returned by [GetPivotOffset].
func (Instance) SetPosition ¶
Sets the Position to given 'position'.
If 'keep_offsets' is true, control's anchors will be updated instead of offsets.
func (Instance) SetRotation ¶
SetRotation sets the property returned by [GetRotation].
func (Instance) SetRotationDegrees ¶
SetRotationDegrees sets the property returned by [GetRotationDegrees].
func (Instance) SetShortcutContext ¶
SetShortcutContext sets the property returned by [GetShortcutContext].
func (Instance) SetSize ¶
Sets the size (see Size).
If 'keep_offsets' is true, control's anchors will be updated instead of offsets.
func (Instance) SetSizeFlagsHorizontal ¶
SetSizeFlagsHorizontal sets the property returned by [GetHSizeFlags].
func (Instance) SetSizeFlagsStretchRatio ¶
SetSizeFlagsStretchRatio sets the property returned by [GetStretchRatio].
func (Instance) SetSizeFlagsVertical ¶
SetSizeFlagsVertical sets the property returned by [GetVSizeFlags].
func (Instance) SetThemeTypeVariation ¶
SetThemeTypeVariation sets the property returned by [GetThemeTypeVariation].
func (Instance) SetTooltipAutoTranslateMode ¶
func (self Instance) SetTooltipAutoTranslateMode(value Node.AutoTranslateMode)
SetTooltipAutoTranslateMode sets the property returned by [GetTooltipAutoTranslateMode].
func (Instance) SetTooltipText ¶
SetTooltipText sets the property returned by [GetTooltipText].
func (Instance) ShortcutContext ¶
The Node which must be a parent of the focused Control for the shortcut to be activated. If null, the shortcut can be activated when any control is focused (a global shortcut). This allows shortcuts to be accepted only when the user has a certain area of the GUI focused.
func (Instance) Size ¶
The size of the node's bounding rectangle, in the node's coordinate system. Container nodes update this property automatically.
func (Instance) SizeFlagsHorizontal ¶
Tells the parent Container nodes how they should resize and place the node on the X axis. Use a combination of the SizeFlags constants to change the flags. See the constants to learn what each does.
func (Instance) SizeFlagsStretchRatio ¶
If the node and at least one of its neighbors uses the SizeExpand size flag, the parent Container will let it take more or less space depending on this property. If this node has a stretch ratio of 2 and its neighbor a ratio of 1, this node will take two thirds of the available space.
func (Instance) SizeFlagsVertical ¶
Tells the parent Container nodes how they should resize and place the node on the Y axis. Use a combination of the SizeFlags constants to change the flags. See the constants to learn what each does.
func (Instance) Theme ¶
The Theme resource this node and all its Control and Window children use. If a child node has its own Theme resource set, theme items are merged with child's definitions having higher priority.
Note: Window styles will have no effect unless the window is embedded.
func (Instance) ThemeTypeVariation ¶
The name of a theme type variation used by this Control to look up its own theme items. When empty, the class name of the node is used (e.g. Button for the Button control), as well as the class names of all parent classes (in order of inheritance).
When set, this property gives the highest priority to the type of the specified name. This type can in turn extend another type, forming a dependency chain. See Theme.SetTypeVariation. If the theme item cannot be found using this type or its base types, lookup falls back on the class names.
Note: To look up Control's own items use various get_theme_* methods without specifying theme_type.
Note: Theme items are looked for in the tree order, from branch to root, where each Control node is checked for its Theme property. The earliest match against any type/class name is returned. The project-level Theme and the default Theme are checked last.
func (Instance) TooltipAutoTranslateMode ¶
func (self Instance) TooltipAutoTranslateMode() Node.AutoTranslateMode
Defines if tooltip text should automatically change to its translated version depending on the current locale. Uses the same auto translate mode as this control when set to [Node.AutoTranslateModeInherit].
Note: Tooltips customized using MakeCustomTooltip do not use this auto translate mode automatically.
func (Instance) TooltipText ¶
The default tooltip text. The tooltip appears when the user's mouse cursor stays idle over this control for a few moments, provided that the MouseFilter property is not MouseFilterIgnore. The time required for the tooltip to appear can be changed with the ProjectSettings "gui/timers/tooltip_delay_sec" setting.
This string is the default return value of GetTooltip. Override GetTooltip to generate tooltip text dynamically. Override MakeCustomTooltip to customize the tooltip interface and behavior.
The tooltip popup will use either a default implementation, or a custom one that you can provide by overriding MakeCustomTooltip. The default tooltip includes a PopupPanel and Label whose theme properties can be customized using Theme methods with the "TooltipPanel" and "TooltipLabel" respectively. For example:
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 GetMinimumSize when the return value is changed. Setting CustomMinimumSize directly calls this method automatically.
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. // // [Vector3i.XYZ]: https://pkg.go.dev/graphics.gd/variant/Vector3i#XYZ StructuredTextParser(args []any, text string) []Vector3i.XYZ // Virtual method to be implemented by the user. Returns the minimum size for this control. Alternative to [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 [Control] node that already overrides its minimum size (e.g. [Label], [Button], [PanelContainer] etc.). It can only be used with most basic GUI nodes, like [Control], [Container], [Panel] etc. // // [Button]: https://pkg.go.dev/graphics.gd/classdb/Button // [Container]: https://pkg.go.dev/graphics.gd/classdb/Container // [Control]: https://pkg.go.dev/graphics.gd/classdb/Control // [CustomMinimumSize]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.CustomMinimumSize // [Label]: https://pkg.go.dev/graphics.gd/classdb/Label // [Panel]: https://pkg.go.dev/graphics.gd/classdb/Panel // [PanelContainer]: https://pkg.go.dev/graphics.gd/classdb/PanelContainer 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 [GetTooltip]. // // Note: If this method returns an empty string and [MakeCustomTooltip] is not overridden, no tooltip is displayed. // // [GetTooltip]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.GetTooltip // [MakeCustomTooltip]: https://pkg.go.dev/graphics.gd/classdb/Control#Interface 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 [CanDropData] and [DropData]. 'at_position' is local to this control. Drag may be forced with [ForceDrag]. // // A preview that will follow the mouse that should represent the data can be set with [SetDragPreview]. A good time to set the preview is in this method. // // Note: If the drag was initiated by a keyboard shortcut or [AccessibilityDrag], 'at_position' is set to [Vector2.Inf], and the currently selected item/text position should be used as the drag position. // // // // [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] // // // // [AccessibilityDrag]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.AccessibilityDrag // [CanDropData]: https://pkg.go.dev/graphics.gd/classdb/Control#Interface // [DropData]: https://pkg.go.dev/graphics.gd/classdb/Control#Interface // [ForceDrag]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.ForceDrag // [SetDragPreview]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.SetDragPreview GetDragData(at_position Vector2.XY) any // Godot calls this method to test if 'data' from a control's [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 [DropData]. // // Note: If the drag was initiated by a keyboard shortcut or [AccessibilityDrag], 'at_position' is set to [Vector2.Inf], and the currently selected item/text position should be used as the drop position. // // // // [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] // // // // [AccessibilityDrag]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.AccessibilityDrag // [DropData]: https://pkg.go.dev/graphics.gd/classdb/Control#Interface // [GetDragData]: https://pkg.go.dev/graphics.gd/classdb/Control#Interface CanDropData(at_position Vector2.XY, data any) bool // Godot calls this method to pass you the 'data' from a control's [GetDragData] result. Godot first calls [CanDropData] to test if 'data' is allowed to drop at 'at_position' where 'at_position' is local to this control. // // Note: If the drag was initiated by a keyboard shortcut or [AccessibilityDrag], 'at_position' is set to [Vector2.Inf], and the currently selected item/text position should be used as the drop position. // // // // [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] // // // // [AccessibilityDrag]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.AccessibilityDrag // [CanDropData]: https://pkg.go.dev/graphics.gd/classdb/Control#Interface // [GetDragData]: https://pkg.go.dev/graphics.gd/classdb/Control#Interface DropData(at_position Vector2.XY, data any) // Virtual method to be implemented by the user. Returns a [Control] node that should be used as a tooltip instead of the default one. 'for_text' is the return value of [GetTooltip]. // // The returned node must be of type [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 [PopupPanel], so you should only provide the contents of that panel. That [PopupPanel] can be themed using [Theme.SetStylebox] for the type "TooltipPanel" (see [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 [CustomMinimumSize] to some non-zero value. // // Note: The node (and any relevant children) should have their [CanvasItem.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 [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] // // // // [CanvasItem.Visible]: https://pkg.go.dev/graphics.gd/classdb/CanvasItem#Instance.Visible // [Control]: https://pkg.go.dev/graphics.gd/classdb/Control // [CustomMinimumSize]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.CustomMinimumSize // [GetTooltip]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.GetTooltip // [PopupPanel]: https://pkg.go.dev/graphics.gd/classdb/PopupPanel // [Theme.SetStylebox]: https://pkg.go.dev/graphics.gd/classdb/Theme#Instance.SetStylebox // [TooltipText]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.TooltipText MakeCustomTooltip(for_text string) Object.Instance // Return the description of the keyboard shortcuts and other contextual help for this control. AccessibilityGetContextualInfo() string // Override this method to return a human-readable description of the position of the child 'node' in the custom container, added to the [AccessibilityName]. // // [AccessibilityName]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.AccessibilityName GetAccessibilityContainerName(node Node.Instance) string // Virtual method to be implemented by the user. Override this method to handle and accept inputs on UI elements. See also [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 [InputEventMouse], this method will not be called when: // // - the control's [MouseFilter] is set to [MouseFilterIgnore]; // // - the control is obstructed by another control on top, that doesn't have [MouseFilter] set to [MouseFilterIgnore]; // // - the control's parent has [MouseFilter] set to [MouseFilterStop] or has accepted the event; // // - the control's parent has [ClipContents] enabled and the 'event”s position is outside the parent's rectangle; // // - the 'event”s position is outside the control (see [HasPoint]). // // Note: The 'event”s position is relative to this control's origin. // // [AcceptEvent]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.AcceptEvent // [ClipContents]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.ClipContents // [HasPoint]: https://pkg.go.dev/graphics.gd/classdb/Control#Interface // [InputEventMouse]: https://pkg.go.dev/graphics.gd/classdb/InputEventMouse // [MouseFilter]: https://pkg.go.dev/graphics.gd/classdb/Control#Instance.MouseFilter 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 [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 [TextServerFallback] ([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 [ProjectSettings] "internationalization/rendering/force_right_to_left_layout_direction". // // [ProjectSettings]: https://pkg.go.dev/graphics.gd/classdb/ProjectSettings // [TextServerFallback]: https://pkg.go.dev/graphics.gd/classdb/TextServerFallback 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 [TextServerFallback] ([ProjectSettings] "internationalization/rendering/text_driver"), left-to-right layout direction is always used regardless of the language. // // [ProjectSettings]: https://pkg.go.dev/graphics.gd/classdb/ProjectSettings // [TextServerFallback]: https://pkg.go.dev/graphics.gd/classdb/TextServerFallback 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 [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset PresetTopLeft LayoutPreset = 0 // Snap all 4 anchors to the top-right of the parent control's bounds. Use with [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset PresetTopRight LayoutPreset = 1 // Snap all 4 anchors to the bottom-left of the parent control's bounds. Use with [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset PresetBottomLeft LayoutPreset = 2 // Snap all 4 anchors to the bottom-right of the parent control's bounds. Use with [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset PresetBottomRight LayoutPreset = 3 // Snap all 4 anchors to the center of the left edge of the parent control's bounds. Use with [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset PresetCenterLeft LayoutPreset = 4 // Snap all 4 anchors to the center of the top edge of the parent control's bounds. Use with [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset PresetCenterTop LayoutPreset = 5 // Snap all 4 anchors to the center of the right edge of the parent control's bounds. Use with [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset PresetCenterRight LayoutPreset = 6 // Snap all 4 anchors to the center of the bottom edge of the parent control's bounds. Use with [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset PresetCenterBottom LayoutPreset = 7 // Snap all 4 anchors to the center of the parent control's bounds. Use with [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#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 [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#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 [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#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 [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#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 [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset PresetBottomWide LayoutPreset = 12 // Snap all 4 anchors to a vertical line that cuts the parent control in half. Use with [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SetAnchorsPreset PresetVcenterWide LayoutPreset = 13 // Snap all 4 anchors to a horizontal line that cuts the parent control in half. Use with [SetAnchorsPreset]. // // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#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 [Control] will fit its parent control. Use with [SetAnchorsPreset]. // // [Control]: https://pkg.go.dev/graphics.gd/classdb/Control // [SetAnchorsPreset]: https://pkg.go.dev/graphics.gd/classdb/#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 MoreArgs ¶
MoreArgs is a container for Instance functions with additional 'optional' arguments.
func (MoreArgs) GetCursorShape ¶
func (self MoreArgs) GetCursorShape(position Vector2.XY) CursorShape
Returns the mouse cursor shape for this control when hovered over 'position' in local coordinates. For most controls, this is the same as MouseDefaultCursorShape, but some built-in controls implement more complex logic.
func (MoreArgs) GetThemeColor ¶
Returns a Color.RGBA from the first matching Theme in the tree if that 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 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 AddThemeColorOverride), then its assigned Theme. After the current control, each parent control and its assigned Theme are considered; controls without a Theme assigned are skipped. If no matching Theme is found in the tree, the custom project Theme (see ProjectSettings "gui/theme/custom") and the default Theme are used (see 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.MoreArgs().GetThemeColor("font_color", "Button")
func (MoreArgs) GetThemeConstant ¶
Returns a constant from the first matching Theme in the tree if that Theme has a constant item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) GetThemeFont ¶
Returns a Font from the first matching Theme in the tree if that Theme has a font item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) GetThemeFontSize ¶
Returns a font size from the first matching Theme in the tree if that Theme has a font size item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) GetThemeIcon ¶
Returns an icon from the first matching Theme in the tree if that Theme has an icon item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) GetThemeStylebox ¶
Returns a StyleBox from the first matching Theme in the tree if that Theme has a stylebox item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) GetTooltip ¶
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 TooltipText.
This method can be overridden to customize its behavior. See GetTooltip.
Note: If this method returns an empty string and MakeCustomTooltip is not overridden, no tooltip is displayed.
func (MoreArgs) HasThemeColor ¶
Returns true if there is a matching Theme in the tree that has a color item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) HasThemeConstant ¶
Returns true if there is a matching Theme in the tree that has a constant item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) HasThemeFont ¶
Returns true if there is a matching Theme in the tree that has a font item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) HasThemeFontSize ¶
Returns true if there is a matching Theme in the tree that has a font size item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) HasThemeIcon ¶
Returns true if there is a matching Theme in the tree that has an icon item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) HasThemeStylebox ¶
Returns true if there is a matching Theme in the tree that has a stylebox item with the specified 'name' and 'theme_type'.
See GetThemeColor for details.
func (MoreArgs) SetAnchor ¶
func (self MoreArgs) 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 AnchorBottom, AnchorLeft, AnchorRight and 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 (MoreArgs) SetAnchorAndOffset ¶
func (self MoreArgs) SetAnchorAndOffset(side Rect2.Side, anchor Float.X, offset Float.X, push_opposite_anchor bool)
Works the same as SetAnchor, but instead of keep_offset argument and automatic update of offset, it allows to set the offset yourself (see SetOffset).
func (MoreArgs) SetAnchorsAndOffsetsPreset ¶
func (self MoreArgs) SetAnchorsAndOffsetsPreset(preset LayoutPreset, resize_mode LayoutPresetMode, margin int)
Sets both anchor preset and offset preset. See SetAnchorsPreset and SetOffsetsPreset.
func (MoreArgs) SetAnchorsPreset ¶
func (self MoreArgs) 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 (MoreArgs) SetGlobalPosition ¶
Sets the GlobalPosition to given 'position'.
If 'keep_offsets' is true, control's anchors will be updated instead of offsets.
func (MoreArgs) SetOffsetsPreset ¶
func (self MoreArgs) 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 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 Control and the edges.
func (MoreArgs) SetPosition ¶
Sets the Position to given 'position'.
If 'keep_offsets' is true, control's anchors will be updated instead of offsets.
type MouseBehaviorRecursive ¶
type MouseBehaviorRecursive int //gd:Control.MouseBehaviorRecursive
const ( // Inherits the [MouseBehaviorRecursive] from the parent control. If there is no parent control, this is the same as [MouseBehaviorEnabled]. // // [MouseBehaviorRecursive]: https://pkg.go.dev/graphics.gd/classdb/#Instance.MouseBehaviorRecursive MouseBehaviorInherited MouseBehaviorRecursive = 0 // Prevents the control from receiving mouse input. [GetMouseFilterWithOverride] will return [MouseFilterIgnore]. // // [GetMouseFilterWithOverride]: https://pkg.go.dev/graphics.gd/classdb/#Instance.GetMouseFilterWithOverride MouseBehaviorDisabled MouseBehaviorRecursive = 1 // Allows the control to be receive mouse input, depending on the [MouseFilter]. This can be used to ignore the parent's [MouseBehaviorRecursive]. [GetMouseFilterWithOverride] will return the [MouseFilter]. // // [GetMouseFilterWithOverride]: https://pkg.go.dev/graphics.gd/classdb/#Instance.GetMouseFilterWithOverride // [MouseBehaviorRecursive]: https://pkg.go.dev/graphics.gd/classdb/#Instance.MouseBehaviorRecursive // [MouseFilter]: https://pkg.go.dev/graphics.gd/classdb/#Instance.MouseFilter MouseBehaviorEnabled MouseBehaviorRecursive = 2 )
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 [GuiInput]. The control will also receive the [OnMouseEntered] and [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. // // [GuiInput]: https://pkg.go.dev/graphics.gd/classdb/#Instance.GuiInput // [OnMouseEntered]: https://pkg.go.dev/graphics.gd/classdb/#Instance.OnMouseEntered // [OnMouseExited]: https://pkg.go.dev/graphics.gd/classdb/#Instance.OnMouseExited MouseFilterStop MouseFilter = 0 // The control will receive mouse movement input events and mouse button input events if clicked on through [GuiInput]. The control will also receive the [OnMouseEntered] and [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-[CanvasItem], a control with [MouseFilterStop], or a [CanvasItem] with [CanvasItem.TopLevel] enabled. This will allow signals to fire in all controls it reaches. If no control handled it, the event will be passed to [Node.ShortcutInput] for further processing. // // [CanvasItem]: https://pkg.go.dev/graphics.gd/classdb/CanvasItem // [CanvasItem.TopLevel]: https://pkg.go.dev/graphics.gd/classdb/CanvasItem#Instance.TopLevel // [GuiInput]: https://pkg.go.dev/graphics.gd/classdb/#Instance.GuiInput // [Node.ShortcutInput]: https://pkg.go.dev/graphics.gd/classdb/Node#Instance.ShortcutInput // [OnMouseEntered]: https://pkg.go.dev/graphics.gd/classdb/#Instance.OnMouseEntered // [OnMouseExited]: https://pkg.go.dev/graphics.gd/classdb/#Instance.OnMouseExited MouseFilterPass MouseFilter = 1 // The control will not receive any mouse movement input events nor mouse button input events through [GuiInput]. The control will also not receive the [OnMouseEntered] nor [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 [OnMouseEntered] but not [OnMouseExited], changing the [MouseFilter] to [MouseFilterIgnore] will cause [OnMouseExited] to be emitted. // // [GuiInput]: https://pkg.go.dev/graphics.gd/classdb/#Instance.GuiInput // [MouseFilter]: https://pkg.go.dev/graphics.gd/classdb/#Instance.MouseFilter // [OnMouseEntered]: https://pkg.go.dev/graphics.gd/classdb/#Instance.OnMouseEntered // [OnMouseExited]: https://pkg.go.dev/graphics.gd/classdb/#Instance.OnMouseExited MouseFilterIgnore MouseFilter = 2 )
type SizeFlags ¶
type SizeFlags int //gd:Control.SizeFlags
const ( // Tells the parent [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 [SizeFlagsHorizontal] and [SizeFlagsVertical]. // // Note: Setting this flag is equal to not having any size flags. // // [Container]: https://pkg.go.dev/graphics.gd/classdb/Container // [SizeFlagsHorizontal]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SizeFlagsHorizontal // [SizeFlagsVertical]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SizeFlagsVertical SizeShrinkBegin SizeFlags = 0 // Tells the parent [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 [SizeFlagsHorizontal] and [SizeFlagsVertical]. // // [Container]: https://pkg.go.dev/graphics.gd/classdb/Container // [SizeFlagsHorizontal]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SizeFlagsHorizontal // [SizeFlagsVertical]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SizeFlagsVertical SizeFill SizeFlags = 1 // Tells the parent [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 [SizeFlagsStretchRatio]. Use with [SizeFlagsHorizontal] and [SizeFlagsVertical]. // // [Container]: https://pkg.go.dev/graphics.gd/classdb/Container // [SizeFlagsHorizontal]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SizeFlagsHorizontal // [SizeFlagsStretchRatio]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SizeFlagsStretchRatio // [SizeFlagsVertical]: https://pkg.go.dev/graphics.gd/classdb/#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 [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 [SizeFlagsHorizontal] and [SizeFlagsVertical]. // // [Container]: https://pkg.go.dev/graphics.gd/classdb/Container // [SizeFlagsHorizontal]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SizeFlagsHorizontal // [SizeFlagsVertical]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SizeFlagsVertical SizeShrinkCenter SizeFlags = 4 // Tells the parent [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 [SizeFlagsHorizontal] and [SizeFlagsVertical]. // // [Container]: https://pkg.go.dev/graphics.gd/classdb/Container // [SizeFlagsHorizontal]: https://pkg.go.dev/graphics.gd/classdb/#Instance.SizeFlagsHorizontal // [SizeFlagsVertical]: https://pkg.go.dev/graphics.gd/classdb/#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 )