Class SplitButton

All Implemented Interfaces:
PointerInterface

public class SplitButton extends Widget
A combined button and dropdown widget.

<picture>
<source srcset="split-button-dark.png" media="(prefers-color-scheme: dark)">
<img src="split-button.png" alt="split-button">
</picture>

`AdwSplitButton` is typically used to present a set of actions in a menu,
but allow access to one of them with a single click.

The API is very similar to [class@Gtk.Button] and [class@Gtk.MenuButton], see
their documentation for details.

## CSS nodes

```
splitbutton[.image-button][.text-button]
├── button
│ ╰── <content>
├── separator
╰── menubutton
╰── button.toggle
╰── arrow
```

`AdwSplitButton`'s CSS node is called `splitbutton`. It contains the css
nodes: `button`, `separator`, `menubutton`. See [class@Gtk.MenuButton]
documentation for the `menubutton` contents.

The main CSS node will contain the `.image-button` or `.text-button` style
classes matching the button contents. The nested button nodes will never
contain them.

## Accessibility

`AdwSplitButton` uses the `GTK_ACCESSIBLE_ROLE_GROUP` role.

https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.SplitButton.html

  • Field Details

  • Constructor Details

    • SplitButton

      public SplitButton(PointerContainer pointer)
    • SplitButton

      public SplitButton()
      Creates a new `AdwSplitButton`.
  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • getChild

      public Widget getChild()
      Gets the child widget.
      Returns:
      the child widget
    • getDirection

      public int getDirection()
      Gets the direction in which the popup will be popped up.
      Overrides:
      getDirection in class Widget
      Returns:
      the direction
    • getDropdownTooltip

      public Str getDropdownTooltip()
      Gets the tooltip of the dropdown button of @self.
      Returns:
      the dropdown tooltip of @self
    • getIconName

      public Str getIconName()
      Gets the name of the icon used to automatically populate the button.
      Returns:
      the icon name
    • getLabel

      public Str getLabel()
      Gets the label for @self.
      Returns:
      the label for @self
    • getMenuModel

      public MenuModel getMenuModel()
      Gets the menu model from which the popup will be created.
      Returns:
      the menu model
    • getPopover

      public Popover getPopover()
      Gets the popover that will be popped up when the dropdown is clicked.
      Returns:
      the popover
    • getUseUnderline

      public boolean getUseUnderline()
      Gets whether an underline in the text indicates a mnemonic.
      Returns:
      whether an underline in the text indicates a mnemonic
    • popdown

      public void popdown()
      Dismisses the menu.
    • popup

      public void popup()
      Pops up the menu.
    • setChild

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

      Setting the child widget will set [property@SplitButton:label] and
      [property@SplitButton:icon-name] to `NULL`.
      Parameters:
      child - the new child widget
    • setDirection

      public void setDirection(int direction)
      Sets the direction in which the popup will be popped up.

      The dropdown arrow icon will point at the same direction.

      If the does not fit in the available space in the given direction, GTK will
      try its best to keep it inside the screen and fully visible.

      If you pass `GTK_ARROW_NONE`, it's equivalent to `GTK_ARROW_DOWN`.
      Overrides:
      setDirection in class Widget
      Parameters:
      direction - the direction
    • setDropdownTooltip

      public void setDropdownTooltip(@Nonnull Str tooltip)
      Sets the tooltip of the dropdown button of @self.

      The tooltip can be marked up with the Pango text markup language.
      Parameters:
      tooltip - the dropdown tooltip of @self
    • setDropdownTooltip

      public void setDropdownTooltip(String tooltip)
      Sets the tooltip of the dropdown button of @self.

      The tooltip can be marked up with the Pango text markup language.
      Parameters:
      tooltip - the dropdown tooltip of @self
    • setIconName

      public void setIconName(@Nonnull Str icon_name)
      Sets the name of the icon used to automatically populate the button.

      Setting the icon name will set [property@SplitButton:label] and
      [property@SplitButton:child] to `NULL`.
      Parameters:
      icon_name - the icon name to set
    • setIconName

      public void setIconName(String icon_name)
      Sets the name of the icon used to automatically populate the button.

      Setting the icon name will set [property@SplitButton:label] and
      [property@SplitButton:child] to `NULL`.
      Parameters:
      icon_name - the icon name to set
    • setLabel

      public void setLabel(@Nonnull Str label)
      Sets the label for @self.

      Setting the label will set [property@SplitButton:icon-name] and
      [property@SplitButton:child] to `NULL`.
      Parameters:
      label - the label to set
    • setLabel

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

      Setting the label will set [property@SplitButton:icon-name] and
      [property@SplitButton:child] to `NULL`.
      Parameters:
      label - the label to set
    • setMenuModel

      public void setMenuModel(@Nullable MenuModel menu_model)
      Sets the menu model from which the popup will be created.

      If the menu model is `NULL`, the dropdown is disabled.

      A [class@Gtk.Popover] will be created from the menu model with
      [ctor@Gtk.PopoverMenu.new_from_model]. Actions will be connected as
      documented for this function.

      If [property@SplitButton:popover] is already set, it will be dissociated from
      the button, and the property is set to `NULL`.
      Parameters:
      menu_model - the menu model
    • setPopover

      public void setPopover(@Nullable Popover popover)
      Sets the popover that will be popped up when the dropdown is clicked.

      If the popover is `NULL`, the dropdown is disabled.

      If [property@SplitButton:menu-model] is set, the menu model is dissociated
      from the button, and the property is set to `NULL`.
      Parameters:
      popover - the popover
    • setUseUnderline

      public void setUseUnderline(boolean use_underline)
      Sets whether an underline in the text indicates a mnemonic.

      See [property@SplitButton:label].
      Parameters:
      use_underline - whether an underline in the text indicates a mnemonic
    • onActivate

      public SignalHandler onActivate(SplitButton.OnActivate signal)
      Connect to signal "activate".
      See SplitButton.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.
    • onClicked

      public SignalHandler onClicked(SplitButton.OnClicked signal)
      Connect to signal "clicked".
      See SplitButton.OnClicked.onClicked() for signal description.
      Field SIGNAL_ON_CLICKED 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()