![](../../../Home/Icons/Home.gif)
![](../icons/UpBook.gif)
![](../icons/BookContext.gif)
![](../../../Home/Icons/Search.gif)
![](../../../Home/Icons/Help.gif)
![](../../icons/button_contents.gif)
![](../../icons/button_previous.gif)
The framework provides a set of concrete classes, derived from abstract Text Editing framework classes and from Desktop framework classes, designed specifically to implement an editable text document component:
This figure shows how these classes work together to form editable text document components, along with the associated interactors:
![](TT105TED.DOC_AFrame_14.gif)
You can customize the behavior of an editable text document component, or extend the functionality, by deriving from these classes. To help you determine what classes you need to extend to provide a particular kind of functionality, the following information describes how instances of these classes work together.
Creating and opening
a document
To create an editable text document component, you need to launch a document with an instance of TTextModel (or TEmbedderTextModel) and an instance of TTextPresenterState, either directly or by using the RunDocument utility with the convenience class TTextStationery, as described in "Getting started: Creating a text document component" on page 86. You can also create text documents within the Workspace--for example, by double-clicking a text stationery icon. The Workspace will provide the primary interface for users to create documents in future releases.
To create the presentation on the document, the framework calls TTextPresenterState::HandleCreatePresenter. This function creates an instance of TTextPresenter, which is responsible for creating the objects specific to a presentation on an editable text document component:
The presenter also creates the TGUIBundle that the document uses to manage all its associated objects and the initial selection on the document. To create the initial selection, the presenter calls TTextModel::CreateSelection, which returns a TDocumentTextSelection.
Some of the necessary interactors are also created when an editable text document component is opened. The view is responsible for creating the interactors and handling the input events. The editable text document component uses three different interactors to handle input:
- A TDocumentTypingInteractor for typing input, created the first time the view is activated. The framework calls HandleCreateTypingInteractor on the current view to instantiate the typing interactor.
- A TSelectTextInteractor for selecting text with the mouse, created each time the user clicks the mouse in the view. The framework calls HandleCreateSelectTextInteractor on the current view to instantiate the selection interactor.
- A TCursorKeyFilter for providing the ability to navigate using cursor arrow keys, created when the view is initialized. The framework calls HandleCreateNavigationKeysBehavior on the current view to add the initial filter. This filter is added as a behavior rather than as an interactor. You can add additional behaviors by calling AdoptBehavior on the text view; you don't need to override HandleCreateNavigationKeysBehavior.
Creating selections
The view for an editable text component uses a TSelectTextInteractor to handle selecting text in the document. The view creates a new selection interactor whenever it receives a mouse-down event; the Input system adopts the interactor and assumes ownership for it.
The selection interactor receives mouse events and uses their positions to compute a new selection area, using the TTextView function CoordinateToInsertionOffset to convert the mouse event positions into offsets within the encapsulated text. If the user simply clicks the mouse, the interactor creates an insertion point selection; if the user clicks and drags the mouse, the interactor creates a selected range.
The interactor computes the area of the final selection, using the simple class TTextArea to encapsulate the selected range, and passes it back to the view by calling TTextView::SetCurrentSelection. The view uses this area to reset the current selection and draw selection feedback.
TSelectTextInteractor can also handle these interactions:
- Extending the current selection by shift-clicking (dragging the mouse with the Shift key pressed)
- Selecting a word by double-clicking
- Selecting a sentence by triple-clicking
Handling typing input
The view uses a TDocumentTypingInteractor to handle typing input for the document. The view instantiates a typing interactor whenever it is activated, and maintains that interactor until the view is deactivated.
When the typing interactor is started, it:
- Gets the typing styles for the current insertion point from the text representation object.
- Uses the language style to determine what typing configuration to use.
- Processes the typing input incrementally, modifying the text representation object as the user enters text. The text representation notifies the view of changes and the view draws the updated text.
- The interactor stops when the view receives a mouse event or when the view is deactivated.
NOTE
The typing and selection interactors are described in more detail in "Text Editing framework interactors" on page 127.
[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