Button

    A themed button that can contain text and an icon.

    Button.swift:24
    class Button

    Button is the standard themed button. It can contain text and an icon, and it will display them according to the current Theme.

    Example of creating a button and assigning an action when pressed by code:

    See also BaseButton which contains common properties and methods associated with this node.

    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.

    Type members

    Instance members

    • var alignment: HorizontalAlignment

      Text alignment policy for the button’s text, use one of the HorizontalAlignment constants.

    • var autowrapMode: TextServer.AutowrapMode

      If set to something other than TextServer/AutowrapMode/autowrapOff, the text gets wrapped inside the node’s bounding rectangle.

    • var clipText: Bool

      When this property is enabled, text that is too large to fit the button is clipped, when disabled the Button will always be wide enough to hold the text.

    • var expandIcon: Bool

      When enabled, the button’s icon will expand/shrink to fit the button’s size while keeping its aspect. See also [theme_item icon_max_width].

    • var flat: Bool

      Flat buttons don’t display decoration.

    • var icon: Texture2D?

      Button’s icon, if text is present the icon will be placed before the text.

    • var iconAlignment: HorizontalAlignment

      Specifies if the icon should be aligned horizontally to the left, right, or center of a button. Uses the same HorizontalAlignment constants as the text alignment. If centered horizontally and vertically, text will draw on top of the icon.

    • var language: String

      Language code used for line-breaking and text shaping algorithms, if left empty current locale is used instead.

    • var text: String

      The button’s text that will be displayed inside the button’s area.

    • var textDirection: Control.TextDirection

      Base text writing direction.

    • var textOverrunBehavior: TextServer.OverrunBehavior

      Sets the clipping behavior when the text exceeds the node’s bounding rectangle. See TextServer.OverrunBehavior for a description of all modes.

    • var verticalIconAlignment: VerticalAlignment

      Specifies if the icon should be aligned vertically to the top, bottom, or center of a button. Uses the same VerticalAlignment constants as the text alignment. If centered horizontally and vertically, text will draw on top of the icon.

    Subclasses