|< Day Day Up >|
Chapter 2. The Keyboard
This chapter describes keyboard and character input, covering topics such as focus, key events, traversal, mnemonics, and accelerators. The intent is to pull together everything you need to know about keyboard handling, rather than distributing it throughout the descriptions of the individual widgets. As such, there will be some forward references to classes, such as MenuItem, that will be covered in more detail later.
Implementing a portable API to provide access to the keyboard across multiple different operating systems is a difficult problem. Even on the same platform, depending on the version of the operating system and the locale, characters can be entered in a variety of ways.
The input method, sometimes called the IM or IME, is a custom character-processing engine that is provided by each operating system. It is responsible for converting sequences of key presses into characters from the user's national language. For example, on a Japanese locale, keystrokes are preprocessed by the IME to allow the user to enter Kanji characters. The GTK widget toolkit is even more flexible: Native applications provide a standard menu item on their context menus to configure the IME and assist in entering international text. Applications that do not provide the standard system menu look out of place. Applications that attempt to emulate this menu suffer from the problem that it can change between releases of the operating system, causing them to look out of date. In addition, a GTK-specific menu might look strange on another platform. Because SWT uses native controls, it displays the menu correctly.
Fortunately, most controls manage the keyboard without requiring program intervention. For example, when the user types Kanji characters in a text control, the control processes the characters and displays them. If there is a standard context menu, it is automatically provided. Nevertheless, you will need to understand how the keyboard support in SWT works in order to write your own widgets, process keys in other widgets, and specify accelerators and mnemonics.
|< Day Day Up >|