Anchor
Control.swift:282enum Anchorenum Anchorimport SwiftGodotFramework to write Godot Game Extensions using the Swift Programming Language.
class ControlBase class for all GUI controls. Adapts its position and size based on its parent control.
case beginSnaps 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(_:keepOffsets:).
case endSnaps 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(_:keepOffsets:).
final func setAnchorsPreset(_ preset: Control.LayoutPreset, keepOffsets: Bool = false) Sets the anchors to a preset from Control.LayoutPreset enum. This is the code equivalent to using the Layout menu in the 2D editor.
static let notificationFocusEnter: IntSent when the node grabs focus.
static let notificationFocusExit: IntSent when the node loses focus.
static let notificationLayoutDirectionChanged: IntSent when control layout direction is changed.
static let notificationMouseEnter: IntSent 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.
static let notificationMouseEnterSelf: IntSent when the mouse cursor enters the 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.
static let notificationMouseExit: IntSent 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.
static let notificationMouseExitSelf: IntSent when the mouse cursor leaves the 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.
static let notificationResized: IntSent when the node changes size. Use size to get the new size.
static let notificationScrollBegin: IntSent when this node is inside a ScrollContainer which has begun being scrolled when dragging the scrollable area with a touch event. This notification is not sent when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
static let notificationScrollEnd: IntSent when this node is inside a ScrollContainer which has stopped being scrolled when dragging the scrollable area with a touch event. This notification is not sent when scrolling by dragging the scrollbar, scrolling with the mouse wheel or scrolling with keyboard/gamepad events.
static let notificationThemeChanged: IntSent when the node needs to refresh its theme items. This happens in one of the following cases:
override class var godotClassName: StringName { get }final var autoTranslate: Bool { get set }Toggles if any text should automatically change to its translated version depending on the current locale.
final var clipContents: Bool { get set }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.
final var customMinimumSize: Vector2 { get set }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).
var focusEntered: SimpleSignal { get }Emitted when the node gains focus.
var focusExited: SimpleSignal { get }Emitted when the node loses focus.
final var focusMode: Control.FocusMode { get set }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, gamepad, and mouse signals.
final var focusNeighborBottom: NodePath { get set }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/uiDown 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.
final var focusNeighborLeft: NodePath { get set }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/uiLeft 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.
final var focusNeighborRight: NodePath { get set }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/uiRight 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.
final var focusNeighborTop: NodePath { get set }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/uiUp 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.
final var focusNext: NodePath { get set }Tells Godot which node it should give focus to if the user presses [kbd]Tab[/kbd] on a keyboard by default. You can change the key by editing the ProjectSettings/input/uiFocusNext input action.
final var focusPrevious: NodePath { get set }Tells Godot which node it should give focus to if the user presses [kbd]Shift + Tab[/kbd] on a keyboard by default. You can change the key by editing the ProjectSettings/input/uiFocusPrev input action.
final var growHorizontal: Control.GrowDirection { get set }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.
final var growVertical: Control.GrowDirection { get set }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.
var guiInput: Signal1 { get }Emitted when the node receives an InputEvent.
final var layoutDirection: Control.LayoutDirection { get set }Controls layout direction and text writing direction. Right-to-left layouts are necessary for certain languages (e.g. Arabic and Hebrew).
final var localizeNumeralSystem: Bool { get set }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.
var minimumSizeChanged: SimpleSignal { get }Emitted when the node’s minimum size changes.
final var mouseDefaultCursorShape: Control.CursorShape { get set }The default cursor shape for this control. Useful for Godot plugins and applications or games that use the system’s mouse cursors.
var mouseEntered: SimpleSignal { get }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.
var mouseExited: SimpleSignal { get }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.
final var mouseFilter: Control.MouseFilter { get set }Controls whether the control will be able to receive mouse button input events through _guiInput(event:) and how these events should be handled. Also controls whether the control can receive the [signal mouse_entered], and [signal mouse_exited] signals. See the constants to learn what each does.
final var mouseForcePassScrollEvents: Bool { get set }When enabled, scroll wheel events processed by _guiInput(event:) will be passed to the parent control even if mouseFilter is set to .stop. As it defaults to true, this allows nested scrollable containers to work out of the box.
final var offsetBottom: Double { get set }Distance between the node’s bottom edge and its parent control, based on anchorBottom.
final var offsetLeft: Double { get set }Distance between the node’s left edge and its parent control, based on anchorLeft.
final var offsetRight: Double { get set }Distance between the node’s right edge and its parent control, based on anchorRight.
final var offsetTop: Double { get set }Distance between the node’s top edge and its parent control, based on anchorTop.
final var pivotOffset: Vector2 { get set }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.
var resized: SimpleSignal { get }Emitted when the control changes size.
final var rotation: Double { get set }The node’s rotation around its pivot, in radians. See pivotOffset to change the pivot’s position.
final var rotationDegrees: Double { get set }Helper property to access rotation in degrees instead of radians.
final var scale: Vector2 { get set }The node’s scale, relative to its size. Change this property to scale the node around its pivotOffset. The Control’s tooltipText will also scale according to this value.
final var shortcutContext: Node? { get set }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.
var sizeFlagsChanged: SimpleSignal { get }Emitted when one of the size flags changes. See sizeFlagsHorizontal and sizeFlagsVertical.
final var sizeFlagsHorizontal: Control.SizeFlags { get set }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.
final var sizeFlagsStretchRatio: Double { get set }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.
final var sizeFlagsVertical: Control.SizeFlags { get set }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.
final var theme: Theme? { get set }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.
var themeChanged: SimpleSignal { get }Emitted when the notificationThemeChanged notification is sent.
final var themeTypeVariation: StringName { get set }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. [code skip-lint]Button` for the Button control), as well as the class names of all parent classes (in order of inheritance).
final var tooltipText: String { get set }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 .ignore. The time required for the tooltip to appear can be changed with the ProjectSettings/gui/timers/tooltipDelaySec option. See also getTooltip(atPosition:).
func _canDropData(atPosition: Vector2, data: Variant) -> Bool Godot calls this method to test if data from a control’s _getDragData(atPosition:) can be dropped at atPosition. atPosition is local to this control.
func _dropData(atPosition: Vector2, data: Variant) Godot calls this method to pass you the data from a control’s _getDragData(atPosition:) result. Godot first calls _canDropData(atPosition:data:) to test if data is allowed to drop at atPosition where atPosition is local to this control.
func _getDragData(atPosition: Vector2) -> Variant 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(atPosition:data:) and _dropData(atPosition:data:). atPosition is local to this control. Drag may be forced with forceDrag(data:preview:).
func _getMinimumSize() -> Vector2 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).
func _getTooltip(atPosition: Vector2) -> String Virtual method to be implemented by the user. Returns the tooltip text for the position atPosition in control’s local coordinates, which will typically appear when the cursor is resting over this control. See getTooltip(atPosition:).
func _guiInput(event: InputEvent?) Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See acceptEvent.
func _hasPoint(_ point: Vector2) -> Bool Virtual method to be implemented by the user. Returns whether the given point is inside this control.
func _makeCustomTooltip(forText: String) -> Object? Virtual method to be implemented by the user. Returns a Control node that should be used as a tooltip instead of the default one. The forText includes the contents of the tooltipText property.
func _structuredTextParser(args: GArray, text: String) -> VariantCollection<Vector3i> User defined BiDi algorithm override function.
final func acceptEvent() Marks an input event as handled. Once you accept an input event, it stops propagating, even to nodes listening to _unhandledInput(event:) or _unhandledKeyInput(event:).
final func addThemeColorOverride(name: StringName, color: Color) Creates a local override for a theme Color with the specified name. Local overrides always take precedence when fetching theme items for the control. An override can be removed with removeThemeColorOverride(name:).
final func addThemeConstantOverride(name: StringName, constant: Int32) 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(name:).
final func addThemeFontOverride(name: StringName, font: Font?) 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(name:).
final func addThemeFontSizeOverride(name: StringName, fontSize: Int32) 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(name:).
final func addThemeIconOverride(name: StringName, texture: Texture2D?) 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(name:).
final func addThemeStyleboxOverride(name: StringName, stylebox: StyleBox?) 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(name:).
final func beginBulkThemeOverride() Prevents *_theme_*_override methods from emitting notificationThemeChanged until endBulkThemeOverride is called.
final func endBulkThemeOverride() Ends a bulk theme override update. See beginBulkThemeOverride.
final func findNextValidFocus() -> Control? Finds the next (below in the tree) Control that can receive the focus.
final func findPrevValidFocus() -> Control? Finds the previous (above in the tree) Control that can receive the focus.
final func findValidFocusNeighbor(side: Side) -> Control? Finds the next Control that can receive the focus on the specified Side.
final func forceDrag(data: Variant, preview: Control?) Forces drag and bypasses _getDragData(atPosition:) and setDragPreview(control:) by passing data and preview. Drag will start even if the mouse is neither over nor pressed on this control.
final func getAnchor(side: Side) -> Double Returns the anchor for the specified Side. A getter method for anchorBottom, anchorLeft, anchorRight and anchorTop.
final func getBegin() -> Vector2 Returns offsetLeft and offsetTop. See also position.
final func getCombinedMinimumSize() -> Vector2 Returns combined minimum size from customMinimumSize and getMinimumSize.
final func getCursorShape(position: Vector2 = Vector2 (x: 0, y: 0)) -> Control.CursorShape Returns the mouse cursor shape the control displays on mouse hover. See CursorShape.
final func getEnd() -> Vector2 Returns offsetRight and offsetBottom.
final func getGlobalPosition() -> Vector2 final func getGlobalRect() -> Rect2 Returns the position and size of the control relative to the containing canvas. See globalPosition and size.
final func getMinimumSize() -> Vector2 Returns the minimum size for this control. See customMinimumSize.
final func getParentAreaSize() -> Vector2 Returns the width/height occupied in the parent control.
final func getParentControl() -> Control? Returns the parent control node.
final func getPosition() -> Vector2 final func getRect() -> Rect2 Returns the position and size of the control in the coordinate system of the containing node. See position, scale and size.
final func getScreenPosition() -> Vector2 Returns the position of this Control in global screen coordinates (i.e. taking window position into account). Mostly useful for editor plugins.
final func getSize() -> Vector2 final func getThemeColor(name: StringName, themeType: StringName = StringName ("")) -> Color Returns a Color from the first matching Theme in the tree if that Theme has a color item with the specified name and themeType. If themeType 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.
final func getThemeConstant(name: StringName, themeType: StringName = StringName ("")) -> Int32 Returns a constant from the first matching Theme in the tree if that Theme has a constant item with the specified name and themeType.
final func getThemeDefaultBaseScale() -> Double Returns the default base scale value from the first matching Theme in the tree if that Theme has a valid defaultBaseScale value.
final func getThemeDefaultFont() -> Font? Returns the default font from the first matching Theme in the tree if that Theme has a valid defaultFont value.
final func getThemeDefaultFontSize() -> Int32 Returns the default font size value from the first matching Theme in the tree if that Theme has a valid defaultFontSize value.
final func getThemeFont(name: StringName, themeType: StringName = StringName ("")) -> Font? Returns a Font from the first matching Theme in the tree if that Theme has a font item with the specified name and themeType.
final func getThemeFontSize(name: StringName, themeType: StringName = StringName ("")) -> Int32 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 themeType.
final func getThemeIcon(name: StringName, themeType: StringName = StringName ("")) -> Texture2D? Returns an icon from the first matching Theme in the tree if that Theme has an icon item with the specified name and themeType.
final func getThemeStylebox(name: StringName, themeType: StringName = StringName ("")) -> StyleBox? Returns a StyleBox from the first matching Theme in the tree if that Theme has a stylebox item with the specified name and themeType.
final func getTooltip(atPosition: Vector2 = Vector2 (x: 0, y: 0)) -> String Returns the tooltip text for the position atPosition in control’s local coordinates, which will typically appear when the cursor is resting over this control. By default, it returns tooltipText.
final func grabClickFocus() Creates an InputEventMouseButton that attempts to click the control. If the event is received, the control acquires focus.
final func grabFocus() Steal the focus from another control and become the focused control (see focusMode).
final func hasFocus() -> Bool Returns true if this is the current focused control. See focusMode.
final func hasThemeColor(name: StringName, themeType: StringName = StringName ("")) -> Bool Returns true if there is a matching Theme in the tree that has a color item with the specified name and themeType.
final func hasThemeColorOverride(name: StringName) -> Bool Returns true if there is a local override for a theme Color with the specified name in this Control node.
final func hasThemeConstant(name: StringName, themeType: StringName = StringName ("")) -> Bool Returns true if there is a matching Theme in the tree that has a constant item with the specified name and themeType.
final func hasThemeConstantOverride(name: StringName) -> Bool Returns true if there is a local override for a theme constant with the specified name in this Control node.
final func hasThemeFont(name: StringName, themeType: StringName = StringName ("")) -> Bool Returns true if there is a matching Theme in the tree that has a font item with the specified name and themeType.
final func hasThemeFontOverride(name: StringName) -> Bool Returns true if there is a local override for a theme Font with the specified name in this Control node.
final func hasThemeFontSize(name: StringName, themeType: StringName = StringName ("")) -> Bool Returns true if there is a matching Theme in the tree that has a font size item with the specified name and themeType.
final func hasThemeFontSizeOverride(name: StringName) -> Bool Returns true if there is a local override for a theme font size with the specified name in this Control node.
final func hasThemeIcon(name: StringName, themeType: StringName = StringName ("")) -> Bool Returns true if there is a matching Theme in the tree that has an icon item with the specified name and themeType.
final func hasThemeIconOverride(name: StringName) -> Bool Returns true if there is a local override for a theme icon with the specified name in this Control node.
final func hasThemeStylebox(name: StringName, themeType: StringName = StringName ("")) -> Bool Returns true if there is a matching Theme in the tree that has a stylebox item with the specified name and themeType.
final func hasThemeStyleboxOverride(name: StringName) -> Bool Returns true if there is a local override for a theme StyleBox with the specified name in this Control node.
final func isDragSuccessful() -> Bool Returns true if a drag operation is successful. Alternative to guiIsDragSuccessful.
final func isLayoutRtl() -> Bool Returns true if layout is right-to-left.
final func releaseFocus() Give up the focus. No other control will be able to receive input.
final func removeThemeColorOverride(name: StringName) Removes a local override for a theme Color with the specified name previously added by addThemeColorOverride(name:color:) or via the Inspector dock.
final func removeThemeConstantOverride(name: StringName) Removes a local override for a theme constant with the specified name previously added by addThemeConstantOverride(name:constant:) or via the Inspector dock.
final func removeThemeFontOverride(name: StringName) Removes a local override for a theme Font with the specified name previously added by addThemeFontOverride(name:font:) or via the Inspector dock.
final func removeThemeFontSizeOverride(name: StringName) Removes a local override for a theme font size with the specified name previously added by addThemeFontSizeOverride(name:fontSize:) or via the Inspector dock.
final func removeThemeIconOverride(name: StringName) Removes a local override for a theme icon with the specified name previously added by addThemeIconOverride(name:texture:) or via the Inspector dock.
final func removeThemeStyleboxOverride(name: StringName) Removes a local override for a theme StyleBox with the specified name previously added by addThemeStyleboxOverride(name:stylebox:) or via the Inspector dock.
final func resetSize() Resets the size to getCombinedMinimumSize. This is equivalent to calling set_size(Vector2()) (or any size below the minimum).
final func setAnchor(side: Side, anchor: Double, keepOffset: Bool = false, pushOppositeAnchor: Bool = true) Sets the anchor for the specified Side to anchor. A setter method for anchorBottom, anchorLeft, anchorRight and anchorTop.
final func setAnchorAndOffset(side: Side, anchor: Double, offset: Double, pushOppositeAnchor: Bool = false) Works the same as setAnchor(side:anchor:keepOffset:pushOppositeAnchor:), but instead of keep_offset argument and automatic update of offset, it allows to set the offset yourself (see setOffset(side:offset:)).
final func setAnchorsAndOffsetsPreset(_ preset: Control.LayoutPreset, resizeMode: Control.LayoutPresetMode = .minsize, margin: Int32 = 0) Sets both anchor preset and offset preset. See setAnchorsPreset(_:keepOffsets:) and setOffsetsPreset(_:resizeMode:margin:).
final func setBegin(position: Vector2) Sets offsetLeft and offsetTop at the same time. Equivalent of changing position.
final func setDragForwarding(dragFunc: Callable, canDropFunc: Callable, dropFunc: Callable) Forwards the handling of this control’s _getDragData(atPosition:), _canDropData(atPosition:data:) and _dropData(atPosition:data:) virtual functions to delegate callables.
final func setDragPreview(control: Control?) Shows the given control at the mouse pointer. A good time to call this method is in _getDragData(atPosition:). 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.
final func setEnd(position: Vector2) Sets offsetRight and offsetBottom at the same time.
final func setGlobalPosition(_ position: Vector2, keepOffsets: Bool = false) Sets the globalPosition to given position.
final func setOffsetsPreset(_ preset: Control.LayoutPreset, resizeMode: Control.LayoutPresetMode = .minsize, margin: Int32 = 0) Sets the offsets to a preset from Control.LayoutPreset enum. This is the code equivalent to using the Layout menu in the 2D editor.
final func setPosition(_ position: Vector2, keepOffsets: Bool = false) Sets the position to given position.
final func setSize(_ size: Vector2, keepOffsets: Bool = false) Sets the size (see size).
final func 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.
final func warpMouse(position: Vector2) Moves the mouse cursor to position, relative to position of this Control.
enum CursorShapeenum FocusModeenum GrowDirectionenum LayoutDirectionenum LayoutPresetenum LayoutPresetModeenum MouseFilterclass Signal1Signal support.
struct SizeFlagsenum TextDirectionclass ContainerBase class for all GUI containers.
protocol CaseIterableA type that provides a collection of all of its values.
protocol CustomDebugStringConvertibleA type with a customized textual representation suitable for debugging purposes.
protocol EquatableA type that can be compared for value equality.
protocol Hashable : EquatableA type that can be hashed into a Hasher to produce an integer hash value.
protocol RawRepresentable<RawValue>A type that can be converted to and from an associated raw value.
init?(rawValue: Int64) var debugDescription: String { get }A textual representation of this instance, suitable for debugging
var hashValue: Int { get }static func != (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether two values are not equal.
func hash(into hasher: inout Hasher)