Package org.gnome.gtk

Class ShortcutController<T extends GObject>

java.lang.Object
All Implemented Interfaces:
Proxy, ListModelJavaList<T>, Iterable<T>, Collection<T>, List<T>, SequencedCollection<T>, ListModel<T>, Buildable

@Generated("io.github.jwharm.JavaGI") public class ShortcutController<T extends GObject> extends EventController implements ListModel<T>, Buildable
GtkShortcutController is an event controller that manages shortcuts.

Most common shortcuts are using this controller implicitly, e.g. by adding a mnemonic underline to a Label, or by installing a key binding using WidgetClass#addBinding, or by adding accelerators to global actions using Application.setAccelsForAction(java.lang.String, java.lang.String[]).

But it is possible to create your own shortcut controller, and add shortcuts to it.

GtkShortcutController implements ListModel for querying the shortcuts that have been added to it.

GtkShortcutController as GtkBuildable
GtkShortcutControllers can be created in GtkBuilder ui files, to set up shortcuts in the same place as the widgets.

An example of a UI definition fragment with GtkShortcutController:

  <object class='GtkButton'>
     <child>
       <object class='GtkShortcutController'>
         <property name='scope'>managed</property>
         <child>
           <object class='GtkShortcut'>
             <property name='trigger'>&lt;Control&gt;k</property>
             <property name='action'>activate</property>
           </object>
         </child>
       </object>
     </child>
   </object>
 

This example creates a ActivateAction for triggering the activate signal of the Button. See ShortcutAction.parseString(java.lang.String) for the syntax for other kinds of ShortcutAction. See ShortcutTrigger.parseString(java.lang.String) to learn more about the syntax for triggers.