Control

    Base class for all GUI controls. Adapts its position and size based on its parent control.

    Control.swift:43
    class Control

    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.

    User Interface nodes and input

    Godot propagates input events via viewports. Each Viewport is responsible for propagating InputEvents to their child nodes. As the 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 _input(event:). For UI elements specifically, it makes more sense to override the virtual method _guiInput(event:), 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 _unhandledInput(event:) 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 .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_theme_*_override methods, like addThemeFontOverride(name:font:). You can override the theme with the Inspector.

    This object emits the following signals:

    Superclasses

    Citizens in SwiftGodot

    Conformances

    • protocol CustomStringConvertible

      A type with a customized textual representation.

    • protocol Equatable

      A type that can be compared for value equality.

    • protocol Hashable

      A type that can be hashed into a Hasher to produce an integer hash value.

    • protocol Identifiable<ID>

      A class of types whose instances hold the value of an entity with stable identity.

    • protocol VariantRepresentable

      Types that conform to VariantRepresentable can be stored directly in Variant with no conversion. These include all of the Variant types from Godot (for example GString, Rect, Plane), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.

    • protocol VariantStorable

      Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.

    Types

    Type members

    Instance members

    Show implementation details (9)

    Hide implementation details

    Subclasses