:right-sidebar: True Shortcut =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: Shortcut(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` A ``GtkShortcut`` describes a keyboard shortcut. It contains a description of how to trigger the shortcut via a :obj:`~gi.repository.Gtk.ShortcutTrigger` and a way to activate the shortcut on a widget via a :obj:`~gi.repository.Gtk.ShortcutAction`. The actual work is usually done via :obj:`~gi.repository.Gtk.ShortcutController`, which decides if and when to activate a shortcut. Using that controller directly however is rarely necessary as various higher level convenience APIs exist on ``GtkWidget``'s that make it easier to use shortcuts in GTK. ``GtkShortcut`` does provide functionality to make it easy for users to work with shortcuts, either by providing informational strings for display purposes or by allowing shortcuts to be configured. Constructors ------------ .. rst-class:: interim-class .. class:: Shortcut :no-index: .. classmethod:: new(trigger: ~gi.repository.Gtk.ShortcutTrigger | None = None, action: ~gi.repository.Gtk.ShortcutAction | None = None) -> ~gi.repository.Gtk.Shortcut Creates a new ``GtkShortcut`` that is triggered by ``trigger`` and then activates ``action``. :param trigger: The trigger that will trigger the shortcut :param action: The action that will be activated upon triggering Methods ------- .. rst-class:: interim-class .. class:: Shortcut :no-index: .. method:: get_action() -> ~gi.repository.Gtk.ShortcutAction | None Gets the action that is activated by this shortcut. .. method:: get_arguments() -> ~gi.repository.GLib.Variant | None Gets the arguments that are passed when activating the shortcut. .. method:: get_trigger() -> ~gi.repository.Gtk.ShortcutTrigger | None Gets the trigger used to trigger ``self``. .. method:: set_action(action: ~gi.repository.Gtk.ShortcutAction | None = None) -> None Sets the new action for ``self`` to be ``action``. :param action: The new action. If the ``action`` is :const:`None`, the nothing action will be used. .. method:: set_arguments(args: ~gi.repository.GLib.Variant | None = None) -> None Sets the arguments to pass when activating the shortcut. :param args: arguments to pass when activating ``self`` .. method:: set_trigger(trigger: ~gi.repository.Gtk.ShortcutTrigger | None = None) -> None Sets the new trigger for ``self`` to be ``trigger``. :param trigger: The new trigger. If the ``trigger`` is :const:`None`, the never trigger will be used. Properties ---------- .. rst-class:: interim-class .. class:: Shortcut :no-index: .. attribute:: props.action :type: ~gi.repository.Gtk.ShortcutAction The action that gets activated by this shortcut. .. attribute:: props.arguments :type: ~gi.repository.GLib.Variant Arguments passed to activation. .. attribute:: props.trigger :type: ~gi.repository.Gtk.ShortcutTrigger The trigger that triggers this shortcut.