Text selection classes

The Text Editing framework text selection classes specify a selection on the data in a text representation object. They are used as targets by Text Editing framework commands to modify the data. The framework also defines a selection class for selecting the presenter state for a text component so that it can be modified.

Text selections

An editable text component always has a current text selection, defined by one of the following:

A text selection object stores one each of these elements, regardless of the current value of the selection. For example, if the selection is a nonzero-length text range, the GetInsertionOffset function returns the last offset in the range. If the selection is an insertion offset, the GetRegion function returns a zero-length range.


MTextSelection defines the abstract protocol for text selections, including access functions for the value of the selection and access to the data represented by the selection. Each text selection object is bound to a specific text representation object. A text selection uses a primitive class, TTextArea, to encapsulate the value of the selection--the insertion offset, text range, and text region. MTextSelection delegates the selection data access functions to TTextArea. See "Representing a text selection" on page 39 for more information on TTextArea.

TDocumentTextSelection is a concrete text selection class used for selections on editable text document components. TDocumentTextSelection derives from TModelSelection, MToolTarget, and MDataExchanger, and implements the protocol for data exchange operations (cut, copy, and paste). A TDocumentTextSelection object is bound to a TTextModel object.

TEmbedderTextSelection adds the protocol for selecting text ranges that contain embedded components.

TSimpleTextSelection is a concrete text selection class used for selections on lightweight text components. A TSimpleTextSelection object is bound to a TSimpleTextStore object.

Presenter state selections

The Text Editing framework provides a single class for creating a selection on a text component's presentation. Use this class to identify the target for tools or commands that modify some aspect of a text presentation--for example, the component color or caret appearance.


TTextPresenterStateSelection, derived from the Compound Document framework class TPresenterStateSelection, identifies a selected document presentation. The selection is represented by the presenter state for the document. To create a TTextPresenterStateSelection, you pass a reference to the presenter state to select. TTextPresenterStateSelection also mixes in MToolTarget.


[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