Next Previous Up Top Contents Index

4.2 Creating a menu hierarchy

4.2.2 Keyboard accelerators

Keyboard accelerators let you define a combination of keys that can be pressed in order to invoke the activate callback of a gadget. This means that you can access the functionality of an application without having to choose commands from menus using the mouse, and can make it much quicker to use an application you are familiar with.

To specify a keyboard accelerator, you need to specify an alphanumeric character, or a function key, together with any modifier keys (such as the CONTROL or ALT keys) that should be held down while the alphanumeric character is pressed. You actually create a keyboard accelerator by calling the make method on <keyboard-gesture>, though to make it a little easier, define the function below, which is used in the definition of each menu button.

define function make-keyboard-gesture
    (keysym :: <symbol>, #rest modifiers)
 => (gesture :: <keyboard-gesture>)
  make(<keyboard-gesture>, keysym: keysym, modifiers: modifiers)
end function make-keyboard-gesture;

Add this definition to the file frame.dylan.

The keyboard accelerators defined demonstrate the several useful points about keyboard accelerators:


Building Applications Using DUIM - 26 May 1999

Next Previous Up Top Contents Index