CheckButton

open class CheckButton : Widget, CheckButtonProtocol

A GtkCheckButton places a label next to an indicator.

Example GtkCheckButtons

A GtkCheckButton is created by calling either [ctorGtk.CheckButton.new] or [ctorGtk.CheckButton.new_with_label].

The state of a GtkCheckButton can be set specifically using [methodGtk.CheckButton.set_active], and retrieved using [methodGtk.CheckButton.get_active].

Inconsistent state

In addition to “on” and “off”, check buttons can be an “in between” state that is neither on nor off. This can be used e.g. when the user has selected a range of elements (such as some text or spreadsheet cells) that are affected by a check button, and the current values in that range are inconsistent.

To set a GtkCheckButton to inconsistent state, use [methodGtk.CheckButton.set_inconsistent].

Grouping

Check buttons can be grouped together, to form mutually exclusive groups - only one of the buttons can be toggled at a time, and toggling another one will switch the currently toggled one off.

Grouped check buttons use a different indicator, and are commonly referred to as radio buttons.

Example GtkCheckButtons

To add a GtkCheckButton to a group, use [methodGtk.CheckButton.set_group].

CSS nodes

checkbutton[.text-button]
├── check
╰── [label]

A GtkCheckButton has a main node with name checkbutton. If the [propertyGtk.CheckButton:label] property is set, it contains a label child. The indicator node is named check when no group is set, and radio if the checkbutton is grouped together with other checkbuttons.

Accessibility

GtkCheckButton uses the GTK_ACCESSIBLE_ROLE_CHECKBOX role.

The CheckButton type acts as a reference-counted owner of an underlying GtkCheckButton instance. It provides the methods that can operate on this data type through CheckButtonProtocol conformance. Use CheckButton as a strong reference or owner of a GtkCheckButton 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 CheckButton instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafeMutablePointer<GtkCheckButton>)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the CheckButton instance.

    Declaration

    Swift

    @inlinable
    public init(_ op: UnsafePointer<GtkCheckButton>)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a non-mutating gpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the CheckButton instance.

    Declaration

    Swift

    @inlinable
    override public init!(gpointer op: gpointer?)

    Parameters

    op

    gpointer to the underlying object

  • Optional initialiser from a non-mutating gconstpointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the CheckButton instance.

    Declaration

    Swift

    @inlinable
    override public init!(gconstpointer op: gconstpointer?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from a constant pointer to the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the CheckButton instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafePointer<GtkCheckButton>?)

    Parameters

    op

    pointer to the underlying object

  • Optional initialiser from the underlying C data type. This creates an instance without performing an unbalanced retain i.e., ownership is transferred to the CheckButton instance.

    Declaration

    Swift

    @inlinable
    public init!(_ op: UnsafeMutablePointer<GtkCheckButton>?)

    Parameters

    op

    pointer to the underlying object

  • Designated initialiser from the underlying C data type. Will retain GtkCheckButton. i.e., ownership is transferred to the CheckButton instance.

    Declaration

    Swift

    @inlinable
    public init(retaining op: UnsafeMutablePointer<GtkCheckButton>)

    Parameters

    op

    pointer to the underlying object

  • Reference intialiser for a related type that implements CheckButtonProtocol Will retain GtkCheckButton.

    Declaration

    Swift

    @inlinable
    public init<T>(checkButton other: T) where T : CheckButtonProtocol

    Parameters

    other

    an instance of a related type that implements CheckButtonProtocol

  • Unsafe typed initialiser. Do not use unless you know the underlying data type the pointer points to conforms to CheckButtonProtocol.

    Declaration

    Swift

    @inlinable
    override public init<T>(cPointer p: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe typed, retaining initialiser. Do not use unless you know the underlying data type the pointer points to conforms to CheckButtonProtocol.

    Declaration

    Swift

    @inlinable
    override public init<T>(retainingCPointer cPointer: UnsafeMutablePointer<T>)

    Parameters

    cPointer

    pointer to the underlying object

  • Unsafe untyped initialiser. Do not use unless you know the underlying data type the pointer points to conforms to CheckButtonProtocol.

    Declaration

    Swift

    @inlinable
    override public init(raw p: UnsafeRawPointer)

    Parameters

    p

    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 CheckButtonProtocol.

    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 CheckButtonProtocol.

    Declaration

    Swift

    @inlinable
    public required init(raw p: UnsafeMutableRawPointer)

    Parameters

    p

    mutable 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 CheckButtonProtocol.

    Declaration

    Swift

    @inlinable
    required public init(retainingRaw raw: UnsafeMutableRawPointer)

    Parameters

    raw

    mutable 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 CheckButtonProtocol.

    Declaration

    Swift

    @inlinable
    override public init(opaquePointer p: OpaquePointer)

    Parameters

    p

    opaque 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 CheckButtonProtocol.

    Declaration

    Swift

    @inlinable
    override public init(retainingOpaquePointer p: OpaquePointer)

    Parameters

    p

    opaque pointer to the underlying object

  • Creates a new GtkCheckButton.

    Declaration

    Swift

    @inlinable
    public init()
  • Creates a new GtkCheckButton with the given text.

    Declaration

    Swift

    @inlinable
    public init(label: UnsafePointer<CChar>? = nil)
  • Creates a new GtkCheckButton with the given text and a mnemonic.

    Declaration

    Swift

    @inlinable
    public init(mnemonic label: UnsafePointer<CChar>? = nil)
  • Creates a new GtkCheckButton with the given text.

    Declaration

    Swift

    @inlinable
    public static func newWith(label: UnsafePointer<CChar>? = nil) -> Widget!
  • Creates a new GtkCheckButton with the given text and a mnemonic.

    Declaration

    Swift

    @inlinable
    public static func newWith(mnemonic label: UnsafePointer<CChar>? = nil) -> Widget!
  • Create a group of check buttons with the given array of labels

    Declaration

    Swift

    @inlinable
    static func groupWith(labels: [String]) -> [CheckButton]

    Parameters

    labels

    array of labels for the check buttons

    Return Value

    grouped array of radio buttons

  • Create a group of radio buttons with the given labels

    Declaration

    Swift

    @inlinable
    static func groupLabeled(_ ls: String...) -> [CheckButton]

    Parameters

    ls

    labels to use for the radio buttons

    Return Value

    grouped array of radio buttons

  • Create a group of check buttons with the given labels. Underscores in the labels denote the mnemonics for the corresponding buttons.

    Declaration

    Swift

    @inlinable
    static func groupWith(mnemonics: [String]) -> [CheckButton]

    Parameters

    mnemonics

    labels to use for the buttons

    Return Value

    grouped array of radio buttons

  • Create a group of check buttons with the given labels Underscores in the labels denote the mnemonics for the corresponding buttons.

    Declaration

    Swift

    @inlinable
    static func groupWithMnemonics(_ ms: String...) -> [CheckButton]

    Parameters

    ms

    labels to use for the buttons

    Return Value

    grouped array of radio buttons