About all my projects
Gnome::Gtk4::ShortcutAction

Gnome::Gtk4::ShortcutAction

Description

Gnome::Gtk4::ShortcutAction 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 Gnome::Gtk4::Shortcut object.

To activate a Gnome::Gtk4::ShortcutAction manually, .activate() can be called.

GTK provides various actions:

  • Gnome::Gtk4::MnemonicAction: a shortcut action that calls gtk_widget_mnemonic_activate()

  • Gnome::Gtk4::CallbackAction: a shortcut action that invokes a given callback

  • Gnome::Gtk4::SignalAction: a shortcut action that emits a given signal

  • Gnome::Gtk4::ActivateAction: a shortcut action that calls gtk_widget_activate()

  • Gnome::Gtk4::NamedAction: a shortcut action that calls gtk_widget_activate_action()

  • Gnome::Gtk4::NothingAction: a shortcut action that does nothing

Class initialization

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object :$native-object! )

parse-string

Tries to parse the given string into an action.

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

The accepted strings are:

  • nothing, for Gnome::Gtk4::NothingAction

  • activate, for Gnome::Gtk4::ActivateAction

  • mnemonic-activate`, for Gnome::Gtk4::MnemonicAction

  • action(NAME)`, for a Gnome::Gtk4::NamedAction for the action named NAME

  • signal(NAME)`, for a Gnome::Gtk4::SignalAction for the signal NAME

method parse-string ( Str $string --> Gnome::Gtk4::ShortcutAction \)
  • $string; the string to parse.

Methods

activate

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.

method activate ( UInt $flags, N-Object() $widget, N-Object $args --> Bool )
  • $flags; flags to activate with.

  • $widget; Target of the activation.

  • $args; arguments to pass

Return value; True if this action was activated successfully.

print

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.

method print ( N-Object $string )
  • $string; a Gnome::Glib::N-String to print into

to-string

Prints the given action into a human-readable string.

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

method to-string (--> Str )

Return value; a new string.