WinForms Shortcuts Overview
Almost each application uses the so-called “Shortcuts” – a keyboard combination that triggers a specific action. For a valid shortcut is considered any keyboard combination where a Modifier Key (
Shift or a combination of these) is down and other key(s) is pressed. This semantic is available out-of-the-box in our framework and allows you to seamlessly plug any valid keys combination as an action accelerator. Supported are also the so-called multiple keys shortcuts where the Keys member of each shortcut may be more than one key – e.g.
S is recognized by the framework. Shortcuts without modifier keys are also supported, but they should be used with caution, since they may be in conflict with other controls which intercept keyboard input.
The Shortcut is part of Telerik UI for WinForms, a
professional grade UI library with 160+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.
The Shortcut is part of Telerik UI for WinForms, a professional grade UI library with 160+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.
How is it done?
The following diagram illustrates the object model and class hierarchy that lie behind each RadShortcut:
The entire mechanism is controlled by several interfaces and classes which provide very easy and intuitive way to register different shortcuts.
RadKeyboardFilter: This class listens to all keyboard messages that come on the application’s message queue and delegates them to each IKeyboardListener registered.
RadShortcutManager: A concrete implementation of IKeyboardListener interface which is plugged into the RadKeyboardFilter instance. It stores a collection of IShortcutProvider instances, recognizes a valid shortcut combination, provided by any of the registered IShortcutProvider and calls the IShortcutProvider.OnShortcut(RadShortcut) callback of the matched provider.
RadItem.Shortcuts: Each RadItem implements the IShortcutProvider interface and allows a number of shortcuts to be associated with it. When a keyboard combination matches any of the item’s shortcuts, the item’s Click event is raised.