Class SplitButton

All Implemented Interfaces:
Accessible, Actionable, Buildable, ConstraintTarget, Proxy

@Generated("org.javagi.JavaGI") public final class SplitButton extends Widget implements Accessible, Actionable, Buildable, ConstraintTarget

A combined button and dropdown widget.

split-button

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 Button and 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 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.

Style classes

AdwSplitButton can use some of the same style classes as Button:

Other style classes, like .pill, cannot be used.

Accessibility

AdwSplitButton uses the Gtk.AccessibleRole.group role.

  • Constructor Details

    • SplitButton

      public SplitButton(MemorySegment address)
      Create a SplitButton instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • SplitButton

      public SplitButton()
      Create a new SplitButton.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the SplitButton class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected SplitButton asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class Widget
      Returns:
      the instance as if it were its parent type
    • getCanShrink

      public boolean getCanShrink()
      gets whether the button can be smaller than the natural size of its contents.
      Returns:
      whether the button can shrink
      Since:
      1.4
    • getChild

      public @Nullable Widget getChild()
      Gets the child widget.
      Returns:
      the child widget
    • getArrowDirection

      public ArrowType getArrowDirection()
      Gets the direction in which the popup will be popped up.
      Returns:
      the direction
    • getDropdownTooltip

      public String getDropdownTooltip()
      Gets the tooltip of the dropdown button of self.
      Returns:
      the dropdown tooltip of this SplitButton
      Since:
      1.2
    • getIconName

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

      public @Nullable String getLabel()
      Gets the label for self.
      Returns:
      the label for this SplitButton
    • getMenuModel

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

      public @Nullable 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.
    • setCanShrink

      public void setCanShrink(boolean canShrink)

      Sets whether the button can be smaller than the natural size of its contents.

      If set to TRUE, the label will ellipsize.

      See Button#setCanShrink and MenuButton#setCanShrink.

      Parameters:
      canShrink - whether the button can shrink
      Since:
      1.4
    • setChild

      public void setChild(@Nullable Widget child)

      Sets the child widget.

      Setting the child widget will set SplitButton:label and SplitButton:icon-name to NULL.

      Parameters:
      child - the new child widget
    • setDirection

      public void setDirection(ArrowType 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.

      Gtk.ArrowType.none behaves same as Gtk.ArrowType.down.

      Parameters:
      direction - the direction
    • 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 this SplitButton
      Since:
      1.2
    • setIconName

      public void setIconName(String iconName)

      Sets the name of the icon used to automatically populate the button.

      Setting the icon name will set SplitButton:label and SplitButton:child to NULL.

      Parameters:
      iconName - the icon name to set
    • setLabel

      public void setLabel(String label)

      Sets the label for self.

      Setting the label will set SplitButton:icon-name and SplitButton:child to NULL.

      Parameters:
      label - the label to set
    • setMenuModel

      public void setMenuModel(@Nullable MenuModel menuModel)

      Sets the menu model from which the popup will be created.

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

      A Popover will be created from the menu model with PopoverMenu#fromModel. Actions will be connected as documented for this function.

      If SplitButton:popover is already set, it will be dissociated from the button, and the property is set to NULL.

      Parameters:
      menuModel - 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 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 useUnderline)

      Sets whether an underline in the text indicates a mnemonic.

      See SplitButton:label.

      Parameters:
      useUnderline - whether an underline in the text indicates a mnemonic
    • onActivate

      Emitted to animate press then release.

      This is an action signal. Applications should never connect to this signal, but use the SplitButton::clicked signal.

      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitActivate

      public void emitActivate()
      Emits the "activate" signal. See onActivate(SplitButton.ActivateCallback).
    • onClicked

      Emitted when the button has been activated (pressed and released).
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      See Also:
    • emitClicked

      public void emitClicked()
      Emits the "clicked" signal. See onClicked(SplitButton.ClickedCallback).
    • builder

      public static SplitButton.Builder<? extends SplitButton.Builder> builder()
      A SplitButton.Builder object constructs a SplitButton with the specified properties. Use the various set...() methods to set properties, and finish construction with SplitButton.Builder.build().
      Returns:
      the builder object