How the typing configuration handles typing input

The typing configuration provides only a portion of the functionality required to process text input. The typing configuration is responsible for:

Each text editor must provide a mechanism for interacting with the typing configuration. The Text Editing framework provides this mechanism with the class TTypingInteractor, derived from TInteractor and MKeyEventHandler. All text components based on the Text Editing framework use this class or a derived class, TDocumentTypingInteractor, to process typing input and to control interaction with the typing configuration.


When a user begins typing into a text component, the view for that component activates the typing interactor to handle the input. As the key events occur, the framework calls the TTypingInteractor functions TypeBegin, TypeIncrement, and TypeEnd to process the keystrokes. These interactor functions are responsible for:

The interaction begins when the user types the first keystroke and ends when either the view is deactivated or the user initiates another kind of interaction--for example, a selection interactor or a cursor tool.

Choosing the typing configuration

In the user environment, one typing configuration is active globally at any given time. For text entered in an empty text input area, TTypingInteractor uses the system typing configuration, or the configuration the user explicitly chooses. End users can alternate between typing configurations as they enter text.

For text input into a nonempty text component, TTypingInteractor attempts to choose the most appropriate typing configuration for the current selection in the text component. For example, if the end user is typing using a global configuration for the English language, but makes a selection in an input area containing Japanese text, the framework switches to a Japanese typing configuration. TTypingInteractor selects a configuration based on the language of the character immediately preceding the selection, choosing the last-selected configuration for that language.

When you create your own typing interaction mechanism, call the TTypingConfigurationHandle functions ChooseConfiguration or GetSystemTypingConfiguration to activate an appropriate configuration. You might also implement a mechanism that does not select a configuration based on language, but changes the configuration only when an end user explicitly requests a change. You would never call ChooseConfiguration when implementing this mechanism.

Representing text during editing

The Typing framework also provides a class, TTypingStore, that provides abstract protocol for representing the text being edited during the typing interaction:


Each text editor must implement these TTypingStore functions:

The text editor must provide its implementation of the typing store to the typing configuration when the configuration is invoked. The Text Editing framework provides two implementations, TDocumentTextTypingStore and TSimpleTextTypingStore, used for typing interactions with editable text document components and with simple editable text elements, respectively. TTypingInteractor constructs and maintains the appropriate typing store object. See "Typing interactors" on page 128 for more information on the Text Editing framework implementation.

The Typing framework also provides a special exception class for use with the typing store. TTypingStoreChangedException should be thrown by your TypeText implementation if a situation occurs in which further typing in the current typing transaction is not possible.

Processing keystrokes

TTypingConfigurationHandle provides the functions that allow you to invoke each element of the typing configuration.

To access the virtual keyboard, TTypingConfigurationHandle provides two functions:

After converting the key event to text, you need to call any text modifiers and the input method. TTypingConfigurationHandle provides mechanisms for both noninteractive and interactive processing of text input.

For noninteractive processing, call the Modify function. Modify takes the following data:

The Modify function generates the replacement text by invoking each modifier in the chain of modifiers. It returns the replacement text and range. You do not need to provide a typing store if you use Modify.

For interactive processing, your interaction mechanism should call the following TTypingConfigurationHandle functions:

  1. Attach, passing the typing store and the presentation on the input method (described in "Input Method framework" on page 186). This function allows the configuration to access the typing callbacks while processing the input. Call this function at the beginning of the typing session--for example, in the typing interactor constructor.
  2. TypeText, to invoke the modifiers and input method. TypeText first calls Modify to invoke the modifiers, and then calls the TypeText function of the typing store. The typing store passes the result of the Modify function to the input method.
  3. TypeEnd, to finalize the transaction. TypeEnd allows the input method to complete its processing and then calls the typing store's TypeEnd function.
  4. Detach--a parallel function to Attach, Detach should be called at the end of each typing session (for example, in the typing interactor destructor).

[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