Input: 3.1 Keyboard Input: Keyboard Input Flow

Up: GEOS SDK TechDocs | Up | Prev: 3 Keyboard Input | Next: 3.2 Keyboard Events

Each time the user presses a character (with or without modifier keys) on the keyboard, the Input Manager generates a single Keyboard event and passes it to the GenSystem object. The GenSystem object delivers the event to all the proper objects based on passive grabs (if any) and the current focus hierarchy.

As with mouse events, all Keyboard events are passed down the object hierarchy from the GenSystem object through an application's GenApplication object and on down to a leaf object. When handling keyboard input, you can choose to intercept the events at the GenApplication level or at any node below it where the event should be handled.

Unlike with mouse input, there is no "implied grab" for keyboard input. Keyboard input is always passed to the object that has the focus (for information on the Focus hierarchy, see Using Focus ). Therefore the focus is the keyboard's "active grab."

Objects can, however, set up passive grabs as they can with mouse input. A pre-passive grab allows the visible object to receive Keyboard events before the focus object gets them. A post-passive grab delivers events to the visible object after they have been sent to the focus. For more information about gaining and releasing the passive keyboard grabs, see the VisClass chapter.

If you intercept Keyboard events, you must be sure to return any events that you don't use. For example, if you only want to detect when the user hits the "a" key, you must return all keypresses that are not "a." Otherwise, your MSG_META_KBD_CHAR handler will eat all keypresses, and keyboard menu navigation will not work. If intercepting Keyboard events in a generic object, you can simply call the superclass for each unused character. If intercepting Keyboard events in a visible object, you must send MSG_META_FUP_KBD_CHAR for each unused character.

To ensure that a particular object (for example, a specific GenText object) automatically will receive keyboard input, you must set HINT_DEFAULT_FOCUS for that object and all its parents up to the GenPrimary containing it. Otherwise, the generic UI does not know which object should gain the default focus.


Up: GEOS SDK TechDocs | Up | Prev: 3 Keyboard Input | Next: 3.2 Keyboard Events