About my projects, examples and tutorials
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.

Uml Diagram§

UNKNOWN image§

=for image :class<inline> :src<asset_files/images/plantuml/ShortcutTrigger.png> :width<70\%>

Example§

Example use of a ShortcutTrigger.

my Gnome::Gtk4::ShortcutTrigger $st .= parse-string('F11');
my Gnome::Gtk4::CallbackAction $ca .= new-callbackaction(
  sub ( N-Object $no, N-Object $, gpointer $ ) {
    say "F6 pressed";
  }, gpointer, gpointer
);
my Gnome::Gtk4::Shortcut $sc .= new-shortcut( $st, $ca);

with my Gnome::Gtk4::ShortcutController $scc .= new-shortcutcontroller() {
  .set-scope(GTK_SHORTCUT_SCOPE_GLOBAL);
  .add-shortcut($sc);
}

with my Gnome::Gtk4::Frame $frame .= new-frame('Shortcut key test') {
  .add-controller($scc);
  …
}
Code

Class initialization§

new§

:native-object§

Create an object using a native object from an object of the same type found elsewhere. See also Gnome::N::TopLevelSupportClass.

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

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:

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

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

Methods§

compare§

The object and the argument must each be of the same Gnome::Gtk4::ShortcutTrigger type.

method compare ( N-Object() $trigger --> Int )
Code
  • $trigger; a Gnome::Gtk4::ShortcutTrigger.

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

equal§

Checks if the object and the argument $trigger trigger under the same conditions. The both must be of the same Gnome::Gtk4::ShortcutTrigger type.

method equal ( N-Object() $trigger --> Bool )
Code
  • $trigger; a Gnome::Gtk4::ShortcutTrigger.

Return value; True if the object and $trigger 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.

method hash (--> UInt )
Code

Return value; a hash value.

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 )
Code

Return value; a new string.

Example§

my Gnome::Gtk4::ShortcutTrigger $trigger .= parse-string('<CTRL>F5');
my Gnome::Gtk4::Window $window .= new-window;
my Gnome::Gdk4::Display() $display = $window.get-display;
my Str $s = $trigger.to-label($display);
say $s;  # Ctrl+F5
Code

to-string§

Prints the given trigger into a human-readable string.

method to-string (--> Str )
Code

Return value; a new string.

Example§

my Gnome::Gtk4::ShortcutTrigger $trigger .= parse-string('<CTRL>F5');
my Str $s = $trigger.to-string();
say $s;  # <Control>F5
Code