Supporting discontiguous selections

To allow you to compute selections on discontiguous text ranges, the functions described in this section return TTextRegion instances. Often these functions simply return a TTextRegion that contains a single TTextRange. However, if the range contains bidirectional text boundaries, the functions return a TTextRegion with multiple TTextRange instances. These appear as a single highlighted area. This mechanism for identifying bidirectional text boundaries prevents the behavior in some systems in which a single text range is computed and characters are highlighted with multiple highlight boxes.

The functions for computing discontiguous ranges are:

TTextLineLayout also provides a function that allows you to extend ranges in a discontiguous selection. GetNearestEdge takes the currently selected region and a mouse position, and returns the insertion offset in the range closest to the position. This offset identifies the insertion point that should be extended when extending a text range.

To implement extendable selections:

  1. Call GetNearestEdge to retrieve the correct TInsertionOffset.
  2. Create a new TTextRegion from this TInsertionOffset and the final mouse position.
  3. Union the new range with the original range to compute the final selection region.

[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