Keyboard Events

The keyboard input system, as well as the mouse input system detailed earlier in this chapter, is built on top of the basic input system provided with the CommonPoint application system.

The CommonPoint application system assumes that there are two types of keys that are used in a keyboard input system: modifier keys and normal keys. The modifier keys (shift, second shift, alt, and caps lock) alter the behavior of normal keys when they are held down at the same time as a normal key.

The state of a keyboard key when an event occurs is packaged into a TKeyEvent object and distributed to interested applications using the MKeyEventHandler object.

Handling input from the keyboard

The MKeyEventHandler class is a mixin class. It is capable of recognizing four kinds of key events:

Handling a keyboard event requires that your application inherits from MKeyEventHandler and that you override the appropriate member function to implement a specific behavior.

The MKeyEventHandler class has two virtual member functions:

Determining the state of modifier keys

The TModifierKey class implements an object that contains the set of states of all of the modifier keys as Boolean values.

This class defines four member functions for each type of modifier key:

The variable modifier can be one of: shift, second shift, alt, or caps lock.

Distributing keyboard events

You will need to have your applications inherit from both MSimpleEventDistributor and TSimpleEventTarget to distribute key events.

Inheriting from the TSimpleEventTarget class enables your application to register itself with the event targeting system. Inheriting from MKeyEventHandler will allow you to manage all other aspects of key events.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker