Class Shortcut

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Shortcut extends GObject

Describes a keyboard shortcut.

It contains a description of how to trigger the shortcut via a ShortcutTrigger and a way to activate the shortcut on a widget via a ShortcutAction.

The actual work is usually done via ShortcutController, which decides if and when to activate a shortcut. Using that controller directly however is rarely necessary as various higher level convenience APIs exist on GtkWidgets that make it easier to use shortcuts in GTK.

GtkShortcut does provide functionality to make it easy for users to work with shortcuts, either by providing informational strings for display purposes or by allowing shortcuts to be configured.

  • Constructor Details

    • Shortcut

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

      public Shortcut(@Nullable ShortcutTrigger trigger, @Nullable ShortcutAction action)
      Creates a new GtkShortcut that is triggered by trigger and then activates action.
      Parameters:
      trigger - The trigger that will trigger the shortcut
      action - The action that will be activated upon triggering
    • Shortcut

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

    • getType

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

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

      protected Shortcut 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 GObject
      Returns:
      the instance as if it were its parent type
    • withArguments

      public static Shortcut withArguments(@Nullable ShortcutTrigger trigger, @Nullable ShortcutAction action, @Nullable String formatString, Object... varargs)
      Creates a new GtkShortcut that is triggered by trigger and then activates action with arguments given by formatString.
      Parameters:
      trigger - The trigger that will trigger the shortcut
      action - The action that will be activated upon triggering
      formatString - GVariant format string for arguments or null for no arguments
      varargs - arguments, as given by format string.
      Returns:
      a new GtkShortcut
    • getAction

      public @Nullable ShortcutAction getAction()
      Gets the action that is activated by this shortcut.
      Returns:
      the action
    • getArguments

      public @Nullable Variant getArguments()
      Gets the arguments that are passed when activating the shortcut.
      Returns:
      the arguments
    • getTrigger

      public @Nullable ShortcutTrigger getTrigger()
      Gets the trigger used to trigger self.
      Returns:
      the trigger used
    • setAction

      public void setAction(@Nullable ShortcutAction action)
      Sets the new action for this Shortcut to be action.
      Parameters:
      action - The new action. If the action is null, the nothing action will be used.
    • setArguments

      public void setArguments(@Nullable Variant args)
      Sets the arguments to pass when activating the shortcut.
      Parameters:
      args - arguments to pass when activating this Shortcut
    • setTrigger

      public void setTrigger(@Nullable ShortcutTrigger trigger)
      Sets the new trigger for this Shortcut to be trigger.
      Parameters:
      trigger - The new trigger. If the trigger is null, the never trigger will be used.
    • builder

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