The RichEdit client API available using the selection property allows you to access and modify selections in a document.
The control keeps the following information about selection:
- the active sub document (activeSubDocument)
- the list of selected intervals (intervals)
- the start and end positions of the last selected interval (start, end, anchor, and active)
Example: in the image below, three intervals are selected. The last interval is selected from right to left. In this case, the properties return the following values.
Selection API allows you to set a cursor position (selection with zero length), select a document interval, multiple intervals, or the entire sub-document. The table below lists methods that allow you to set selection.
|Set the cursor position||setSelection(position)||
|Select an interval||setSelection(interval)||
|Select several intervals||setSelection(interval)||
|Select the entire sub-document||selectAll||