Class ShortcutAction

All Implemented Interfaces:
PointerInterface
Direct Known Subclasses:
ActivateAction, CallbackAction, MnemonicAction, NamedAction, NothingAction, SignalAction

public class ShortcutAction extends Object
`GtkShortcutAction` 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, [method@Gtk.ShortcutAction.activate]
can be called.

GTK provides various actions:

- [class@Gtk.MnemonicAction]: a shortcut action that calls
gtk_widget_mnemonic_activate()
- [class@Gtk.CallbackAction]: a shortcut action that invokes
a given callback
- [class@Gtk.SignalAction]: a shortcut action that emits a
given signal
- [class@Gtk.ActivateAction]: a shortcut action that calls
gtk_widget_activate()
- [class@Gtk.NamedAction]: a shortcut action that calls
gtk_widget_activate_action()
- [class@Gtk.NothingAction]: a shortcut action that does nothing

https://docs.gtk.org/gtk4/class.ShortcutAction.html

  • Constructor Details

  • Method Details

    • getClassHandler

      public static ClassHandler getClassHandler()
    • parseStringShortcutAction

      public static ShortcutAction parseStringShortcutAction(@Nonnull Str 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`
    • parseStringShortcutAction

      public static ShortcutAction parseStringShortcutAction(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(int flags, @Nonnull 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(@Nonnull GString 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
    • toStr

      public Str toStr()
      Prints the given action into a human-readable string.

      This is a small wrapper around [method@Gtk.ShortcutAction.print]
      to help when debugging.
      Returns:
      a new string
    • 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()