Text control classes

This figure shows the classes you use to create a text control. For simple text controls, use TTextControl and TSimpleTextControlState. For controls that generate actions, use the class TTextActionControlState.


Control state classes

MTextControlState provides the basic protocol for manipulating the text associated with a text control. Each text control adopts a text control state, which maintains the underlying text data (the text state) for the text control. When a user edits a text control, the text control calls text control state functions to access the text data. The text control state also determines whether the text control is currently enabled for input.

The system includes two concrete text control state classes for simple text controls and for text controls that generate actions:

Generating actions from a text control
To create a text control that can generate actions, build your control using the control state class TTextActionControlState, which generates actions as instances of the class TTextControlAction. TTextControlAction identifies the
following actions:
  • kEmpty
  • kNotEmpty
  • kActivate
  • kDeactivate
You might use these actions, for example, to enable a push button based on the text entered into the control, or to launch a particular behavior based on what the
user enters.
To handle text actions, you can use the handler MTextControlActionHandler. This handler can handle only text actions. Implement HandleTextControlAction to provide the behavior you want. If you also need to handle other actions, you can use MViewActionHandler. In this case, you need to cast text actions from TViewAction to TTextControlAction.

Control classes

TTextControl is a convenience class that implements a text control. TTextControl adopts a text control state at construction time to maintain the underlying text data. You can use TTextControl with both TSimpleTextControlState and TTextActionControlState. A text control can also have a label associated with it.

TTextControl derives from several classes that add functionality to the text control:

To create your own text control class, derive directly from MDelegatingTextControl. TTextControl is provided as a convenience class appropriate for a range of standard needs, but it is not designed to be extended.


[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