Class CheckButton

All Implemented Interfaces:
PointerInterface

public class CheckButton extends Widget
A `GtkCheckButton` places a label next to an indicator.

![Example GtkCheckButtons](check-button.png)

A `GtkCheckButton` is created by calling either [ctor@Gtk.CheckButton.new]
or [ctor@Gtk.CheckButton.new_with_label].

The state of a `GtkCheckButton` can be set specifically using
[method@Gtk.CheckButton.set_active], and retrieved using
[method@Gtk.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
[method@Gtk.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](radio-button.png)

To add a `GtkCheckButton` to a group, use [method@Gtk.CheckButton.set_group].

# CSS nodes

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

A `GtkCheckButton` has a main node with name checkbutton. If the
[property@Gtk.CheckButton:label] or [property@Gtk.CheckButton:child]
properties are set, it contains a child widget. 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.

https://docs.gtk.org/gtk4/class.CheckButton.html

  • Field Details

  • Constructor Details

    • CheckButton

      public CheckButton(PointerContainer pointer)
    • CheckButton

      public CheckButton()
      Creates a new `GtkCheckButton`.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • newWithLabelCheckButton

      public static CheckButton newWithLabelCheckButton(@Nullable Str label)
      Creates a new `GtkCheckButton` with the given text.
      Parameters:
      label - the text for the check button.
      Returns:
      a new `GtkCheckButton`
    • newWithLabelCheckButton

      public static CheckButton newWithLabelCheckButton(String label)
      Creates a new `GtkCheckButton` with the given text.
      Parameters:
      label - the text for the check button.
      Returns:
      a new `GtkCheckButton`
    • newWithMnemonicCheckButton

      public static CheckButton newWithMnemonicCheckButton(@Nullable Str label)
      Creates a new `GtkCheckButton` with the given text and a mnemonic.
      Parameters:
      label - The text of the button, with an underscore in front of the mnemonic character
      Returns:
      a new `GtkCheckButton`
    • newWithMnemonicCheckButton

      public static CheckButton newWithMnemonicCheckButton(String label)
      Creates a new `GtkCheckButton` with the given text and a mnemonic.
      Parameters:
      label - The text of the button, with an underscore in front of the mnemonic character
      Returns:
      a new `GtkCheckButton`
    • getActive

      public boolean getActive()
      Returns whether the check button is active.
      Returns:
      whether the check button is active
    • getChild

      public Widget getChild()
      Gets the child widget of @button or `NULL` if [property@CheckButton:label] is set.
      Returns:
      the child widget of @button
    • getInconsistent

      public boolean getInconsistent()
      Returns whether the check button is in an inconsistent state.
      Returns:
      %TRUE if @check_button is currently in an inconsistent state
    • getLabel

      public Str getLabel()
      Returns the label of the check button or `NULL` if [property@CheckButton:child] is set.
      Returns:
      The label @self shows next to the indicator. If no label is shown, %NULL will be returned.
    • getUseUnderline

      public boolean getUseUnderline()
      Returns whether underlines in the label indicate mnemonics.
      Returns:
      The value of the [property@Gtk.CheckButton:use-underline] property. See [method@Gtk.CheckButton.set_use_underline] for details on how to set a new value.
    • setActive

      public void setActive(boolean setting)
      Changes the check buttons active state.
      Parameters:
      setting - the new value to set
    • setChild

      public void setChild(@Nullable Widget child)
      Sets the child widget of @button.

      Note that by using this API, you take full responsibility for setting
      up the proper accessibility label and description information for @button.
      Most likely, you'll either set the accessibility label or description
      for @button explicitly, or you'll set a labelled-by or described-by
      relations from @child to @button.
      Parameters:
      child - the child widget
    • setGroup

      public void setGroup(@Nullable CheckButton group)
      Adds @self to the group of @group.

      In a group of multiple check buttons, only one button can be active
      at a time. The behavior of a checkbutton in a group is also commonly
      known as a *radio button*.

      Setting the group of a check button also changes the css name of the
      indicator widget's CSS node to 'radio'.

      Setting up groups in a cycle leads to undefined behavior.

      Note that the same effect can be achieved via the [iface@Gtk.Actionable]
      API, by using the same action with parameter type and state type 's'
      for all buttons in the group, and giving each button its own target
      value.
      Parameters:
      group - another `GtkCheckButton` to form a group with
    • setInconsistent

      public void setInconsistent(boolean inconsistent)
      Sets the `GtkCheckButton` to inconsistent state.

      You shoud turn off the inconsistent state again if the user checks
      the check button. This has to be done manually.
      Parameters:
      inconsistent - %TRUE if state is inconsistent
    • setLabel

      public void setLabel(@Nullable Str label)
      Sets the text of @self.

      If [property@Gtk.CheckButton:use-underline] is %TRUE, an underscore
      in @label is interpreted as mnemonic indicator, see
      [method@Gtk.CheckButton.set_use_underline] for details on this behavior.
      Parameters:
      label - The text shown next to the indicator, or %NULL to show no text
    • setLabel

      public void setLabel(String label)
      Sets the text of @self.

      If [property@Gtk.CheckButton:use-underline] is %TRUE, an underscore
      in @label is interpreted as mnemonic indicator, see
      [method@Gtk.CheckButton.set_use_underline] for details on this behavior.
      Parameters:
      label - The text shown next to the indicator, or %NULL to show no text
    • setUseUnderline

      public void setUseUnderline(boolean setting)
      Sets whether underlines in the label indicate mnemonics.

      If @setting is %TRUE, an underscore character in @self's label
      indicates a mnemonic accelerator key. This behavior is similar
      to [property@Gtk.Label:use-underline].
      Parameters:
      setting - the new value to set
    • onActivate

      public SignalHandler onActivate(CheckButton.OnActivate signal)
      Connect to signal "activate".
      See CheckButton.OnActivate.onActivate() for signal description.
      Field SIGNAL_ON_ACTIVATE contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • onToggled

      public SignalHandler onToggled(CheckButton.OnToggled signal)
      Connect to signal "toggled".
      See CheckButton.OnToggled.onToggled() for signal description.
      Field SIGNAL_ON_TOGGLED contains original signal name and can be used as resource reference.
      Parameters:
      signal - callback function (lambda).
      Returns:
      SignalHandler. Can be used to disconnect signal and to release callback function.
    • asAccessible

      public Accessible asAccessible()
      Implements interface Accessible. Call this to get access to interface functions.
      Overrides:
      asAccessible in class Widget
      Returns:
      Accessible
    • asActionable

      public Actionable asActionable()
      Implements interface Actionable. Call this to get access to interface functions.
      Returns:
      Actionable
    • asBuildable

      public Buildable asBuildable()
      Implements interface Buildable. Call this to get access to interface functions.
      Overrides:
      asBuildable in class Widget
      Returns:
      Buildable
    • asConstraintTarget

      public ConstraintTarget asConstraintTarget()
      Implements interface ConstraintTarget. Call this to get access to interface functions.
      Overrides:
      asConstraintTarget in class Widget
      Returns:
      ConstraintTarget
    • getTypeID

      public static long getTypeID()
    • getParentTypeID

      public static long getParentTypeID()
    • getTypeSize

      public static TypeSystem.TypeSize getTypeSize()
    • getParentTypeSize

      public static TypeSystem.TypeSize getParentTypeSize()
    • getInstanceSize

      public static int getInstanceSize()