Gnome::Gtk4::ShortcutTrigger
#------------------------------------------------------------------------------- #--[Class Description]---------------------------------------------------------- #-------------------------------------------------------------------------------
=begin rakudoc
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
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);
β¦
}
=end rakudoc
#------------------------------------------------------------------------------- #--[Class Initialization]------------------------------------------------------- #-------------------------------------------------------------------------------
=begin rakudoc
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! )
=end rakudoc
#------------------------------------------------------------------------------- =begin rakudoc
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 `<` instead of `<` and `>` instead of `>`.
method parse-string ( Str $string --> Gnome::Gtk4::ShortcutTrigger )
$string; the string to parse.
=end rakudoc
#------------------------------------------------------------------------------- #--[Methods]-------------------------------------------------------------------- #-------------------------------------------------------------------------------
=begin rakudoc
Methods =end rakudoc
#------------------------------------------------------------------------------- =begin rakudoc
compare
The object and the argument must each be of the same Gnome::Gtk4::ShortcutTrigger type.
method compare ( N-Object() $trigger --> Int )
$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.
=end rakudoc
#------------------------------------------------------------------------------- =begin rakudoc
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 )
$trigger; a Gnome::Gtk4::ShortcutTrigger.
Return value; True if the object and $trigger are equal.
=end rakudoc
#------------------------------------------------------------------------------- =begin rakudoc
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 )
Return value; a hash value.
=end rakudoc
#`{{ #------------------------------------------------------------------------------- =begin rakudoc
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
=end rakudoc
#------------------------------------------------------------------------------- =begin rakudoc
print-label
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..
=end rakudoc }}
#------------------------------------------------------------------------------- =begin rakudoc
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.
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
=end rakudoc
#------------------------------------------------------------------------------- =begin rakudoc
to-string
Prints the given trigger into a human-readable string.
method to-string (--> Str )
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
=end rakudoc
#`{{ #------------------------------------------------------------------------------- =begin rakudoc
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;
Trueif mnemonics should trigger. Usually the value of this property is determined by checking that the passed in$eventis a Key event and has the right modifiers set..
Return value; Whether the event triggered the shortcut. }}