ShortcutTrigger#
Superclasses: Object
Subclasses: AlternativeTrigger
, KeyvalTrigger
, MnemonicTrigger
, NeverTrigger
GtkShortcutTrigger
tracks how a GtkShortcut
should be activated.
To find out if a GtkShortcutTrigger
triggers, you can call
trigger
on a GdkEvent
.
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.
Constructors#
- class ShortcutTrigger
- classmethod parse_string(string: str) ShortcutTrigger | None #
Tries to parse the given string into a trigger.
On success, the parsed trigger is returned. When parsing failed,
None
is returned.The accepted strings are:
never
, forGtkNeverTrigger
a string parsed by
accelerator_parse()
, for aGtkKeyvalTrigger
, e.g.<Control>C
underscore, followed by a single character, for
GtkMnemonicTrigger
, e.g._l
two valid trigger strings, separated by a
|
character, for aGtkAlternativeTrigger
:<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>
.- Parameters:
string – the string to parse
Methods#
- class ShortcutTrigger
- compare(trigger2: ShortcutTrigger) int #
The types of
trigger1
andtrigger2
aregconstpointer
only to allow use of this function as aGCompareFunc
.They must each be a
GtkShortcutTrigger
.- Parameters:
trigger2 – a
GtkShortcutTrigger
- equal(trigger2: ShortcutTrigger) bool #
Checks if
trigger1
andtrigger2
trigger under the same conditions.The types of
one
andtwo
aregconstpointer
only to allow use of this function withGHashTable
. They must each be aGtkShortcutTrigger
.- Parameters:
trigger2 – a
GtkShortcutTrigger
- hash() int #
Generates a hash value for a
GtkShortcutTrigger
.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
isgconstpointer
only to allow use of this function withGHashTable
. They must each be aGtkShortcutTrigger
.
- print_label(display: Display, string: String) bool #
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.
- Parameters:
display –
GdkDisplay
to print forstring – a
GString
to print into
- to_label(display: Display) str #
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.
- Parameters:
display –
GdkDisplay
to print for
- to_string() str #
Prints the given trigger into a human-readable string.
This is a small wrapper around
print
to help when debugging.
- trigger(event: Event, enable_mnemonics: bool) KeyMatch #
Checks if the given
event
triggersself
.- Parameters:
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 inevent
is a Key event and has the right modifiers set.