Button
open class Button : Widget, ButtonProtocol
The GtkButton widget is generally used to trigger a callback function that is
called when the button is pressed.

The GtkButton widget can hold any valid child widget. That is, it can hold
almost any other standard GtkWidget. The most commonly used child is the
GtkLabel.
CSS nodes
GtkButton has a single CSS node with name button. The node will get the
style classes .image-button or .text-button, if the content is just an
image or label, respectively. It may also receive the .flat style class.
When activating a button via the keyboard, the button will temporarily
gain the .keyboard-activating style class.
Other style classes that are commonly used with GtkButton include
.suggested-action and .destructive-action. In special cases, buttons
can be made round by adding the .circular style class.
Button-like widgets like [classGtk.ToggleButton], [classGtk.MenuButton],
[classGtk.VolumeButton], [classGtk.LockButton], [classGtk.ColorButton]
or [classGtk.FontButton] use style classes such as .toggle, .popup, .scale,
.lock, .color on the button node to differentiate themselves from a plain
GtkButton.
Accessibility
GtkButton uses the GTK_ACCESSIBLE_ROLE_BUTTON role.
The Button type acts as a reference-counted owner of an underlying GtkButton instance.
It provides the methods that can operate on this data type through ButtonProtocol conformance.
Use Button as a strong reference or owner of a GtkButton instance.
-
Designated initialiser from the underlying `C` data type.This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the
Buttoninstance.Declaration
Swift
@inlinable public init(_ op: UnsafeMutablePointer<GtkButton>)Parameters
oppointer to the underlying object
-
Designated initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theButtoninstance.Declaration
Swift
@inlinable public init(_ op: UnsafePointer<GtkButton>)Parameters
oppointer to the underlying object
-
Optional initialiser from a non-mutating
gpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theButtoninstance.Declaration
Swift
@inlinable override public init!(gpointer op: gpointer?)Parameters
opgpointer to the underlying object
-
Optional initialiser from a non-mutating
gconstpointerto the underlyingCdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theButtoninstance.Declaration
Swift
@inlinable override public init!(gconstpointer op: gconstpointer?)Parameters
oppointer to the underlying object
-
Optional initialiser from a constant pointer to the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theButtoninstance.Declaration
Swift
@inlinable public init!(_ op: UnsafePointer<GtkButton>?)Parameters
oppointer to the underlying object
-
Optional initialiser from the underlying
Cdata type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to theButtoninstance.Declaration
Swift
@inlinable public init!(_ op: UnsafeMutablePointer<GtkButton>?)Parameters
oppointer to the underlying object
-
Designated initialiser from the underlying
Cdata type. Will retainGtkButton. i.e., ownership is transferred to theButtoninstance.Declaration
Swift
@inlinable public init(retaining op: UnsafeMutablePointer<GtkButton>)Parameters
oppointer to the underlying object
-
Reference intialiser for a related type that implements
ButtonProtocolWill retainGtkButton.Declaration
Swift
@inlinable public init<T>(button other: T) where T : ButtonProtocolParameters
otheran instance of a related type that implements
ButtonProtocol -
Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable override public init<T>(cPointer p: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)Parameters
cPointerpointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable override public init(raw p: UnsafeRawPointer)Parameters
praw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable override public init(retainingRaw raw: UnsafeRawPointer) -
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable public required init(raw p: UnsafeMutableRawPointer)Parameters
pmutable raw pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable required public init(retainingRaw raw: UnsafeMutableRawPointer)Parameters
rawmutable raw pointer to the underlying object
-
Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable override public init(opaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Unsafe untyped, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to
ButtonProtocol.Declaration
Swift
@inlinable override public init(retainingOpaquePointer p: OpaquePointer)Parameters
popaque pointer to the underlying object
-
Creates a new
GtkButtonwidget.To add a child widget to the button, use [method
Gtk.Button.set_child].Declaration
Swift
@inlinable public init() -
Creates a new button containing an icon from the current icon theme.
If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.
Declaration
Swift
@inlinable public init(iconName: UnsafePointer<CChar>? = nil) -
Creates a
GtkButtonwidget with aGtkLabelchild.Declaration
Swift
@inlinable public init(label: UnsafePointer<CChar>!) -
Creates a new
GtkButtoncontaining a label.If characters in
labelare preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.Declaration
Swift
@inlinable public init(mnemonic label: UnsafePointer<CChar>!) -
Creates a new button containing an icon from the current icon theme.
If the icon name isn’t known, a “broken image” icon will be displayed instead. If the current icon theme is changed, the icon will be updated appropriately.
Declaration
Swift
@inlinable public static func newFrom(iconName: UnsafePointer<CChar>? = nil) -> Widget! -
Creates a
GtkButtonwidget with aGtkLabelchild.Declaration
Swift
@inlinable public static func newWith(label: UnsafePointer<CChar>!) -> Widget! -
Creates a new
GtkButtoncontaining a label.If characters in
labelare preceded by an underscore, they are underlined. If you need a literal underscore character in a label, use “__” (two underscores). The first underlined character represents a keyboard accelerator called a mnemonic. Pressing Alt and that key activates the button.Declaration
Swift
@inlinable public static func newWith(mnemonic label: UnsafePointer<CChar>!) -> Widget!
View on GitHub
Install in Dash
Button Class Reference