Class ShortcutLabel

All Implemented Interfaces:
Accessible, Buildable, ConstraintTarget, Proxy

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

A widget that displays a keyboard shortcut.

shortcut-label

The shown shortcut can be set using the ShortcutLabel:accelerator property.

Optionally, if no shortcut is set, AdwShortcutLabel will display a placeholder set with the ShortcutLabel:disabled-text property.

The following types of shortcuts can be displayed:

  • A single shortcut in Gtk#acceleratorParse format, e.g. <Control>C:

    shortcut-label-single
  • Multiple alternative shortcuts, separated with spaces, e.g. <Shift>A Home:

    shortcut-label-alternative
  • A range of shortcuts, separated with ..., e.g. <Alt>1...9:

    shortcut-label-range
  • Multiple keys pressed at once, separated with &, e.g. Control_L&Control_R:

    shortcut-label-multiple
  • Multiple shortcuts or keys, pressed sequentially, separated with +, e.g. <Control>C+<Control>X:

    shortcut-label-sequence

::: note <, > and & need to be escaped as &lt;, &gt; and &amp; when used in UI files.

CSS nodes

AdwShortcutLabel has a single CSS node with name shortcut-label. The individual keycap labels each have the .keycap style class, while the labels separating them have the .dimmed style class.

Accessibility

AdwShortcutLabel uses the Gtk.AccessibleRole.label role.

See also: ShortcutsDialog.

Since:
1.8
  • Constructor Details

    • ShortcutLabel

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

      public ShortcutLabel(String accelerator)
      Creates a new AdwShortcutLabel showing accelerator.
      Parameters:
      accelerator - the accelerator to show
      Since:
      1.8
    • ShortcutLabel

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

    • getType

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

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

      protected ShortcutLabel 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
    • getAccelerator

      public String getAccelerator()
      Gets the accelerator displayed by self.
      Returns:
      the displayed accelerator
      Since:
      1.8
    • getDisabledText

      public String getDisabledText()
      Gets the text displayed by this ShortcutLabel when no accelerator is set.
      Returns:
      the text displayed when no accelerator is set
      Since:
      1.8
    • setAccelerator

      public void setAccelerator(String accelerator)
      Sets the accelerator to be displayed by self.
      Parameters:
      accelerator - the accelerator to be displayed
      Since:
      1.8
    • setDisabledText

      public void setDisabledText(String disabledText)
      Sets the text to be displayed by this ShortcutLabel when no accelerator is set.
      Parameters:
      disabledText - the text displayed when no accelerator is set
      Since:
      1.8
    • builder

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