:right-sidebar: True ShortcutTrigger =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: ShortcutTrigger(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Subclasses: :class:`~gi.repository.Gtk.AlternativeTrigger`, :class:`~gi.repository.Gtk.KeyvalTrigger`, :class:`~gi.repository.Gtk.MnemonicTrigger`, :class:`~gi.repository.Gtk.NeverTrigger` ``GtkShortcutTrigger`` tracks how a ``GtkShortcut`` should be activated. To find out if a ``GtkShortcutTrigger`` triggers, you can call :obj:`~gi.repository.Gtk.ShortcutTrigger.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 ------------ .. rst-class:: interim-class .. class:: ShortcutTrigger :no-index: .. classmethod:: parse_string(string: str) -> ~gi.repository.Gtk.ShortcutTrigger | None Tries to parse the given string into a trigger. On success, the parsed trigger is returned. When parsing failed, :const:`None` is returned. The accepted strings are: - ``never``, for ``GtkNeverTrigger`` - a string parsed by :func:`~gi.repository.Gtk.accelerator_parse`, for a ``GtkKeyvalTrigger``, e.g. ``C`` - underscore, followed by a single character, for ``GtkMnemonicTrigger``, e.g. ``_l`` - two valid trigger strings, separated by a ``|`` character, for a ``GtkAlternativeTrigger``: ``q|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 ``>``. :param string: the string to parse Methods ------- .. rst-class:: interim-class .. class:: ShortcutTrigger :no-index: .. method:: compare(trigger2: ~gi.repository.Gtk.ShortcutTrigger) -> int The types of ``trigger1`` and ``trigger2`` are ``gconstpointer`` only to allow use of this function as a ``GCompareFunc``. They must each be a ``GtkShortcutTrigger``. :param trigger2: a ``GtkShortcutTrigger`` .. method:: equal(trigger2: ~gi.repository.Gtk.ShortcutTrigger) -> bool 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 ``GHashTable``. They must each be a ``GtkShortcutTrigger``. :param trigger2: a ``GtkShortcutTrigger`` .. method:: 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`` is ``gconstpointer`` only to allow use of this function with ``GHashTable``. They must each be a ``GtkShortcutTrigger``. .. method:: print_(string: ~gi.repository.GLib.String) -> None :param string: .. method:: print_label(display: ~gi.repository.Gdk.Display, string: ~gi.repository.GLib.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. :param display: ``GdkDisplay`` to print for :param string: a ``GString`` to print into .. method:: to_label(display: ~gi.repository.Gdk.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. :param display: ``GdkDisplay`` to print for .. method:: to_string() -> str Prints the given trigger into a human-readable string. This is a small wrapper around :obj:`~gi.repository.Gtk.ShortcutTrigger.print` to help when debugging. .. method:: trigger(event: ~gi.repository.Gdk.Event, enable_mnemonics: bool) -> ~gi.repository.Gdk.KeyMatch Checks if the given ``event`` triggers ``self``. :param event: the event to check :param enable_mnemonics: :const:`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.