Class ShortcutAction

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
ActivateAction, CallbackAction, MnemonicAction, NamedAction, NothingAction, ShortcutAction.ShortcutAction$Impl, SignalAction

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

Encodes an action that can be triggered by a keyboard shortcut.

GtkShortcutActions contain functions that allow easy presentation to end users as well as being printed for debugging.

All GtkShortcutActions are immutable, you can only specify their properties during construction. If you want to change a action, you have to replace it with a new one. If you need to pass arguments to an action, these are specified by the higher-level GtkShortcut object.

To activate a GtkShortcutAction manually, activate(Set, Widget, Variant) can be called.

GTK provides various actions:

  • Constructor Details

    • ShortcutAction

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

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

    • getType

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

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

      protected ShortcutAction 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
    • parseString

      public static @Nullable ShortcutAction parseString(String string)

      Tries to parse the given string into an action.

      On success, the parsed action is returned. When parsing failed, null is returned.

      The accepted strings are:

      • nothing, for GtkNothingAction
      • activate, for GtkActivateAction
      • mnemonic-activate, for GtkMnemonicAction
      • action(NAME), for a GtkNamedAction for the action named NAME
      • signal(NAME), for a GtkSignalAction for the signal NAME
      Parameters:
      string - the string to parse
      Returns:
      a new GtkShortcutAction
    • activate

      public boolean activate(Set<ShortcutActionFlags> flags, Widget widget, @Nullable Variant args)

      Activates the action on the widget with the given args.

      Note that some actions ignore the passed in flags, widget or args.

      Activation of an action can fail for various reasons. If the action is not supported by the widget, if the args don't match the action or if the activation otherwise had no effect, false will be returned.

      Parameters:
      flags - flags to activate with
      widget - Target of the activation
      args - arguments to pass
      Returns:
      true if this action was activated successfully
    • activate

      public boolean activate(ShortcutActionFlags flags, Widget widget, @Nullable Variant args)

      Activates the action on the widget with the given args.

      Note that some actions ignore the passed in flags, widget or args.

      Activation of an action can fail for various reasons. If the action is not supported by the widget, if the args don't match the action or if the activation otherwise had no effect, false will be returned.

      Parameters:
      flags - flags to activate with
      widget - Target of the activation
      args - arguments to pass
      Returns:
      true if this action was activated successfully
    • print

      public void print(String string)

      Prints the given action into a string for the developer.

      This is meant for debugging and logging.

      The form of the representation may change at any time and is not guaranteed to stay identical.

      Parameters:
      string - a GString to print into
    • toString

      public String toString()

      Prints the given action into a human-readable string.

      This is a small wrapper around print(String) to help when debugging.

      Overrides:
      toString in class Object
      Returns:
      a new string