About all my projects
Gnome::Gtk4::ShortcutTrigger

Gnome::Gtk4::ShortcutTrigger

Description

Gnome::Gtk4::ShortcutTrigger tracks how a Gnome::Gtk4::Shortcut should be activated.

To find out if a Gnome::Gtk4::ShortcutTrigger triggers, you can call .trigger() on a Gnome::Gdk4::Event.

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

All GtkShortcutTriggers are immutable, you can only specify their properties during construction. If you want to change a trigger, you have to replace it with a new one.

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 a trigger.

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

The accepted strings are:

  • never, for Gnome::Gtk4::NeverTrigger

  • a string parsed by gtk_accelerator_parse(), for a Gnome::Gtk4::KeyvalTrigger, e.g. `<Control>C`

  • underscore, followed by a single character, for Gnome::Gtk4::MnemonicTrigger, e.g. _l

  • two valid trigger strings, separated by a `|` character, for a Gnome::Gtk4::AlternativeTrigger: `<Control>q|<Control>w`

Note that you will have to escape the `<` and `>` characters when specifying triggers in XML files, such as GtkBuilder ui files. Use `&lt;` instead of `<` and `&gt;` instead of `>`.

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

Methods

compare

The types of $trigger1 and $trigger2 are gconstpointer only to allow use of this function as a Gnome::Glib::T-types.

They must each be a Gnome::Gtk4::ShortcutTrigger.

method compare ( gpointer $trigger2 --> Int )
  • $trigger2; a Gnome::Gtk4::ShortcutTrigger.

Return value; An integer less than, equal to, or greater than zero if $trigger1 is found, respectively, to be less than, to match, or be greater than $trigger2..

equal

Checks if $trigger1 and $trigger2 trigger under the same conditions.

The types of $one and $two are gconstpointer only to allow use of this function with Gnome::Glib::N-HashTable. They must each be a Gnome::Gtk4::ShortcutTrigger.

method equal ( gpointer $trigger2 --> Bool )
  • $trigger2; a Gnome::Gtk4::ShortcutTrigger.

Return value; True if $trigger1 and $trigger2 are equal.

hash

Generates a hash value for a Gnome::Gtk4::ShortcutTrigger.

The output of this function is guaranteed to be the same for a given value only per-process. It may change between different processor architectures or even different versions of GTK. Do not use this function as a basis for building protocols or file formats.

The types of $trigger is gconstpointer only to allow use of this function with Gnome::Glib::N-HashTable. They must each be a Gnome::Gtk4::ShortcutTrigger.

method hash (--> UInt )

Return value; a hash value corresponding to $trigger.

print

Prints the given trigger 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

Prints the given trigger into a string.

This function is returning a translated string for presentation to end users for example in menu items or in help texts.

The $display in use may influence the resulting string in various forms, such as resolving hardware keycodes or by causing display-specific modifier names.

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

method print-label ( N-Object() $display, N-Object $string --> Bool )
  • $display; Gnome::Gdk4::Display to print for.

  • $string; a Gnome::Glib::N-String to print into

Return value; True if something was printed or False if the trigger did not have a textual representation suitable for end users..

to-label

Gets textual representation for the given trigger.

This function is returning a translated string for presentation to end users for example in menu items or in help texts.

The $display in use may influence the resulting string in various forms, such as resolving hardware keycodes or by causing display-specific modifier names.

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

method to-label ( N-Object() $display --> Str )
  • $display; Gnome::Gdk4::Display to print for.

Return value; a new string.

to-string

Prints the given trigger 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.

trigger This function is not yet available

Checks if the given $event triggers $self.

method trigger ( N-Object() $event, Bool() $enable-mnemonics --> GdkKeyMatch  )
  • $event; the event to check.

  • $enable-mnemonics; True if mnemonics should trigger. Usually the value of this property is determined by checking that the passed in $event is a Key event and has the right modifiers set..

Return value; Whether the event triggered the shortcut.