Control

All User Interface nodes inherit from Control. A control's anchors and margins adapt its position and size relative to its parent.

Base class for all User Interface or UI related nodes. Control features a bounding rectangle that defines its extents, an anchor position relative to its parent and margins that represent an offset to the anchor. The margins update automatically when the node, any of its parents, or the screen size change. For more information on Godot's UI system, anchors, margins, 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. User Interface nodes and input Godot sends input events to the scene's root node first, by calling Node._input. Node._input forwards the event down the node tree to the nodes under the mouse cursor, or on keyboard focus. To do so, it calls MainLoop._inputEvent. Call acceptEvent so no other node receives the event. Once you accepted an input, it becomes handled so Node._unhandledInput will not process it. Only one Control node can be in keyboard focus. Only the node in focus will receive keyboard events. To get the focus, call grabFocus. Control nodes lose focus when another node grabs it, or if you hide the node in focus. Set mouseFilter to MOUSE_FILTER_IGNORE 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. If you change the Theme on a Control node, it affects all of its children. To override some of the theme's parameters, call one of the add_*_override methods, like addFontOverride. You can override the theme with the inspector.

@GodotBaseClass
struct Control {}

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Enums

Anchor
enum Anchor
Constants
enum Constants
CursorShape
enum CursorShape
FocusMode
enum FocusMode
GrowDirection
enum GrowDirection
LayoutPreset
enum LayoutPreset
LayoutPresetMode
enum LayoutPresetMode
MouseFilter
enum MouseFilter
SizeFlags
enum SizeFlags

Functions

_clipsInput
bool _clipsInput()
_fontChanged
void _fontChanged()
_getMinimumSize
Vector2 _getMinimumSize()

Returns the minimum size for this control. See rectMinSize.

_getTooltip
String _getTooltip()
_guiInput
void _guiInput(InputEvent event)

Use this method to process and accept inputs on UI elements. See acceptEvent. Replaces Godot 2's _input_event.

_makeCustomTooltip
GodotObject _makeCustomTooltip(StringArg0 for_text)
_setAnchor
void _setAnchor(long margin, double anchor)
_sizeChanged
void _sizeChanged()
_themeChanged
void _themeChanged()
_updateMinimumSize
void _updateMinimumSize()
acceptEvent
void 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.

addColorOverride
void addColorOverride(StringArg0 name, Color color)

Overrides the color in the theme resource the node uses.

addConstantOverride
void addConstantOverride(StringArg0 name, long constant)

Overrides an integer constant in the theme resource the node uses. If the constant is invalid, Godot clears the override.

addFontOverride
void addFontOverride(StringArg0 name, Font font)

Overrides the name font in the theme resource the node uses. If font is empty, Godot clears the override.

addIconOverride
void addIconOverride(StringArg0 name, Texture texture)

Overrides the name icon in the theme resource the node uses. If icon is empty, Godot clears the override.

addShaderOverride
void addShaderOverride(StringArg0 name, Shader shader)

Overrides the name shader in the theme resource the node uses. If shader is empty, Godot clears the override.

addStyleboxOverride
void addStyleboxOverride(StringArg0 name, StyleBox stylebox)

Overrides the name Stylebox in the theme resource the node uses. If stylebox is empty, Godot clears the override.

canDropData
bool canDropData(Vector2 position, VariantArg1 data)

Godot calls this method to test if data from a control's getDragData can be dropped at position. position is local to this control. This method should only be used to test the data. Process the data in dropData.

dropData
void dropData(Vector2 position, VariantArg1 data)

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 position where position is local to this control.

forceDrag
void forceDrag(VariantArg0 data, GodotObject preview)

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.

getAnchor
double getAnchor(long margin)
getBegin
Vector2 getBegin()

Returns marginLeft and marginTop. See also rectPosition.

getColor
Color getColor(StringArg0 name, StringArg1 type)
getCombinedMinimumSize
Vector2 getCombinedMinimumSize()
getConstant
long getConstant(StringArg0 name, StringArg1 type)
getCursorShape
Control.CursorShape getCursorShape(Vector2 position)

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

getCustomMinimumSize
Vector2 getCustomMinimumSize()
getDefaultCursorShape
Control.CursorShape getDefaultCursorShape()
getDragData
GodotObject getDragData(Vector2 position)

Godot calls this method to get data that can be dragged and dropped onto controls that expect drop data. Return null if there is no data to drag. Controls that want to receive drop data should implement canDropData and dropData. 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.

getEnd
Vector2 getEnd()

Returns marginRight and marginBottom.

getFocusMode
Control.FocusMode getFocusMode()
getFocusNeighbour
NodePath getFocusNeighbour(long margin)
getFocusNext
NodePath getFocusNext()
getFocusOwner
Control getFocusOwner()

Returns the control that has the keyboard focus or null if none.

getFocusPrevious
NodePath getFocusPrevious()
getFont
Ref!Font getFont(StringArg0 name, StringArg1 type)
getGlobalPosition
Vector2 getGlobalPosition()
getGlobalRect
Rect2 getGlobalRect()

Returns the position and size of the control relative to the top-left corner of the screen. See rectPosition and rectSize.

getHGrowDirection
Control.GrowDirection getHGrowDirection()
getHSizeFlags
long getHSizeFlags()
getIcon
Ref!Texture getIcon(StringArg0 name, StringArg1 type)
getMargin
double getMargin(long margin)
getMinimumSize
Vector2 getMinimumSize()

Returns the minimum size for this control. See rectMinSize.

getMouseFilter
Control.MouseFilter getMouseFilter()
getParentAreaSize
Vector2 getParentAreaSize()

Returns the width/height occupied in the parent control.

getParentControl
Control getParentControl()

Returns the parent control node.

getPivotOffset
Vector2 getPivotOffset()
getPosition
Vector2 getPosition()
getRect
Rect2 getRect()

Returns the position and size of the control relative to the top-left corner of the parent Control. See rectPosition and rectSize.

getRotation
double getRotation()

Returns the rotation (in radians).

getRotationDegrees
double getRotationDegrees()
getScale
Vector2 getScale()
getSize
Vector2 getSize()
getStretchRatio
double getStretchRatio()
getStylebox
Ref!StyleBox getStylebox(StringArg0 name, StringArg1 type)
getTheme
Ref!Theme getTheme()
getTooltip
String getTooltip(Vector2 at_position)

Returns the tooltip, which will appear when the cursor is resting over this control.

getVGrowDirection
Control.GrowDirection getVGrowDirection()
getVSizeFlags
long getVSizeFlags()
grabClickFocus
void grabClickFocus()
grabFocus
void grabFocus()

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

hasColor
bool hasColor(StringArg0 name, StringArg1 type)
hasColorOverride
bool hasColorOverride(StringArg0 name)
hasConstant
bool hasConstant(StringArg0 name, StringArg1 type)
hasConstantOverride
bool hasConstantOverride(StringArg0 name)
hasFocus
bool hasFocus()

Returns true if this is the current focused control. See focusMode.

hasFont
bool hasFont(StringArg0 name, StringArg1 type)
hasFontOverride
bool hasFontOverride(StringArg0 name)
hasIcon
bool hasIcon(StringArg0 name, StringArg1 type)
hasIconOverride
bool hasIconOverride(StringArg0 name)
hasPoint
bool hasPoint(Vector2 point)
hasShaderOverride
bool hasShaderOverride(StringArg0 name)
hasStylebox
bool hasStylebox(StringArg0 name, StringArg1 type)
hasStyleboxOverride
bool hasStyleboxOverride(StringArg0 name)
isClippingContents
bool isClippingContents()
minimumSizeChanged
void minimumSizeChanged()
opAssign
Control opAssign(T n)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(typeof(null) n)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Control other)
Undocumented in source. Be warned that the author may not have intended to support it.
releaseFocus
void releaseFocus()

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

setAnchor
void setAnchor(long margin, double anchor, bool keep_margin, bool push_opposite_anchor)
setAnchorAndMargin
void setAnchorAndMargin(long margin, double anchor, double offset, bool push_opposite_anchor)
setAnchorsAndMarginsPreset
void setAnchorsAndMarginsPreset(long preset, long resize_mode, long margin)
setAnchorsPreset
void setAnchorsPreset(long preset, bool keep_margin)
setBegin
void setBegin(Vector2 position)

Sets marginLeft and marginTop at the same time.

setClipContents
void setClipContents(bool enable)
setCustomMinimumSize
void setCustomMinimumSize(Vector2 size)
setDefaultCursorShape
void setDefaultCursorShape(long shape)
setDragForwarding
void setDragForwarding(GodotObject target)

Forwards the handling of this control's drag and drop to target control. Forwarding can be implemented in the target control similar to the methods getDragData, canDropData, and dropData but with two differences: 1. The function name must be suffixed with _fw 2. The function must take an extra argument that is the control doing the forwarding

setDragPreview
void setDragPreview(GodotObject control)

Shows the given control at the mouse pointer. A good time to call this method is in getDragData.

setEnd
void setEnd(Vector2 position)

Sets marginRight and marginBottom at the same time.

setFocusMode
void setFocusMode(long mode)
setFocusNeighbour
void setFocusNeighbour(long margin, NodePathArg1 neighbour)
setFocusNext
void setFocusNext(NodePathArg0 next)
setFocusPrevious
void setFocusPrevious(NodePathArg0 previous)
setGlobalPosition
void setGlobalPosition(Vector2 position)
setHGrowDirection
void setHGrowDirection(long direction)
setHSizeFlags
void setHSizeFlags(long flags)
setMargin
void setMargin(long margin, double offset)
setMarginsPreset
void setMarginsPreset(long preset, long resize_mode, long margin)
setMouseFilter
void setMouseFilter(long filter)
setPivotOffset
void setPivotOffset(Vector2 pivot_offset)
setPosition
void setPosition(Vector2 position)
setRotation
void setRotation(double radians)

Sets the rotation (in radians).

setRotationDegrees
void setRotationDegrees(double degrees)
setScale
void setScale(Vector2 scale)
setSize
void setSize(Vector2 size)
setStretchRatio
void setStretchRatio(double ratio)
setTheme
void setTheme(Theme theme)
setTooltip
void setTooltip(StringArg0 tooltip)
setVGrowDirection
void setVGrowDirection(long direction)
setVSizeFlags
void setVSizeFlags(long flags)
showModal
void showModal(bool exclusive)

Displays a control as modal. Control must be a subwindow. Modal controls capture the input signals until closed or the area outside them is accessed. When a modal control loses focus, or the ESC key is pressed, they automatically hide. Modal controls are used extensively for popup dialogs and menus.

warpMouse
void warpMouse(Vector2 to_position)

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Properties

anchorBottom
double anchorBottom [@property getter]
double anchorBottom [@property setter]

Anchors the bottom edge of the node to the origin, the center, or the end of its parent container. It changes how the bottom margin updates when the node moves or changes size. Use one of the ANCHOR_* constants. Default value: ANCHOR_BEGIN.

anchorLeft
double anchorLeft [@property getter]
double anchorLeft [@property setter]

Anchors the left edge of the node to the origin, the center or the end of its parent container. It changes how the left margin updates when the node moves or changes size. Use one of the ANCHOR_* constants. Default value: ANCHOR_BEGIN.

anchorRight
double anchorRight [@property getter]
double anchorRight [@property setter]

Anchors the right edge of the node to the origin, the center or the end of its parent container. It changes how the right margin updates when the node moves or changes size. Use one of the ANCHOR_* constants. Default value: ANCHOR_BEGIN.

anchorTop
double anchorTop [@property getter]
double anchorTop [@property setter]

Anchors the top edge of the node to the origin, the center or the end of its parent container. It changes how the top margin updates when the node moves or changes size. Use one of the ANCHOR_* constants. Default value: ANCHOR_BEGIN.

focusMode
Control.FocusMode focusMode [@property getter]
long focusMode [@property setter]

The focus access mode for the control (None, Click or All). Only one Control can be focused at the same time, and it will receive keyboard signals.

focusNeighbourBottom
NodePath focusNeighbourBottom [@property getter]
NodePath focusNeighbourBottom [@property setter]

Tells Godot which node it should give keyboard focus to if the user presses Tab, the down arrow on the keyboard, or down on a gamepad. 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. If the user presses Tab, Godot will give focus to the closest node to the right first, then to the bottom. If the user presses Shift+Tab, Godot will look to the left of the node, then above it.

focusNeighbourLeft
NodePath focusNeighbourLeft [@property getter]
NodePath focusNeighbourLeft [@property setter]

Tells Godot which node it should give keyboard focus to if the user presses Shift+Tab, the left arrow on the keyboard or left on a gamepad. 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.

focusNeighbourRight
NodePath focusNeighbourRight [@property getter]
NodePath focusNeighbourRight [@property setter]

Tells Godot which node it should give keyboard focus to if the user presses Tab, the right arrow on the keyboard or right on a gamepad. 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.

focusNeighbourTop
NodePath focusNeighbourTop [@property getter]
NodePath focusNeighbourTop [@property setter]

Tells Godot which node it should give keyboard focus to if the user presses Shift+Tab, the top arrow on the keyboard or top on a gamepad. 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.

focusNext
NodePath focusNext [@property getter]
NodePath focusNext [@property setter]
focusPrevious
NodePath focusPrevious [@property getter]
NodePath focusPrevious [@property setter]
growHorizontal
Control.GrowDirection growHorizontal [@property getter]
long growHorizontal [@property setter]
growVertical
Control.GrowDirection growVertical [@property getter]
long growVertical [@property setter]
hintTooltip
String hintTooltip [@property getter]
String hintTooltip [@property setter]

Changes the tooltip text. The tooltip appears when the user's mouse cursor stays idle over this control for a few moments.

marginBottom
double marginBottom [@property getter]
double marginBottom [@property setter]

Distance between the node's bottom edge and its parent container, based on anchorBottom. Margins are often controlled by one or multiple parent Container nodes. Margins update automatically when you move or resize the node.

marginLeft
double marginLeft [@property getter]
double marginLeft [@property setter]

Distance between the node's left edge and its parent container, based on anchorLeft.

marginRight
double marginRight [@property getter]
double marginRight [@property setter]

Distance between the node's right edge and its parent container, based on anchorRight.

marginTop
double marginTop [@property getter]
double marginTop [@property setter]

Distance between the node's top edge and its parent container, based on anchorTop.

mouseDefaultCursorShape
Control.CursorShape mouseDefaultCursorShape [@property getter]
long mouseDefaultCursorShape [@property setter]

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.

mouseFilter
Control.MouseFilter mouseFilter [@property getter]
long mouseFilter [@property setter]

Controls whether the control will be able to receive mouse button input events through _guiInput and how these events should be handled. Use one of the MOUSE_FILTER_* constants. See the constants to learn what each does.

rectClipContent
bool rectClipContent [@property getter]
bool rectClipContent [@property setter]
rectGlobalPosition
Vector2 rectGlobalPosition [@property getter]
Vector2 rectGlobalPosition [@property setter]

The node's global position, relative to the world (usually to the top-left corner of the window).

rectMinSize
Vector2 rectMinSize [@property getter]
Vector2 rectMinSize [@property setter]

The minimum size of the node's bounding rectangle. If you set it to a value greater than (0, 0), the node's bounding rectangle will always have at least this size, even if its content is smaller. If it's set to (0, 0), the node sizes automatically to fit its content, be it a texture or child nodes.

rectPivotOffset
Vector2 rectPivotOffset [@property getter]
Vector2 rectPivotOffset [@property setter]

By default, the node's pivot is its top-left corner. When you change its rectScale, it will scale around this pivot. Set this property to rectSize / 2 to center the pivot in the node's rectangle.

rectPosition
Vector2 rectPosition [@property getter]
Vector2 rectPosition [@property setter]

The node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by rectPivotOffset.

rectRotation
double rectRotation [@property getter]
double rectRotation [@property setter]

The node's rotation around its pivot, in degrees. See rectPivotOffset to change the pivot's position.

rectScale
Vector2 rectScale [@property getter]
Vector2 rectScale [@property setter]

The node's scale, relative to its rectSize. Change this property to scale the node around its rectPivotOffset.

rectSize
Vector2 rectSize [@property getter]
Vector2 rectSize [@property setter]

The size of the node's bounding rectangle, in pixels. Container nodes update this property automatically.

sizeFlagsHorizontal
long sizeFlagsHorizontal [@property setter]

Tells the parent Container nodes how they should resize and place the node on the X axis. Use one of the SIZE_* constants to change the flags. See the constants to learn what each does.

sizeFlagsHorizontal
long sizeFlagsHorizontal [@property getter]

Tells the parent Container nodes how they should resize and place the node on the X axis. Use one of the SIZE_* constants to change the flags. See the constants to learn what each does.

sizeFlagsStretchRatio
double sizeFlagsStretchRatio [@property getter]
double sizeFlagsStretchRatio [@property setter]

If the node and at least one of its neighbours uses the SIZE_EXPAND 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 neighbour a ratio of 1, this node will take two thirds of the available space.

sizeFlagsVertical
long sizeFlagsVertical [@property getter]
long sizeFlagsVertical [@property setter]

Tells the parent Container nodes how they should resize and place the node on the Y axis. Use one of the SIZE_* constants to change the flags. See the constants to learn what each does.

theme
Theme theme [@property getter]
Theme theme [@property setter]

Changing this property replaces the current Theme resource this node and all its Control children use.

Static functions

_new
Control _new()
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

_classBinding
struct _classBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
To as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
ToRef as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta