Editor.Selection.setRange
Description
Change the selection in the Editor to the supplied range.
First, obtain anXopusRange object. Then configure it to contain specific contents, or to be in a specific spot. Then use setRange() to place the selection there.
This example selects the text in a title element.
var title = Editor.getActiveDocument().selectSingleNode("//title");
var range = Editor.Selection.getRange();
// Change the selection:
range.selectNodeContents(title);
Editor.Selection.setRange(range);
This example places the caret at the end of the title:
var title = Editor.getActiveDocument().selectSingleNode("//title");
var range = Editor.Selection.getRange();
// Change the selection:
range.selectNode(title);
range.collapse();
Editor.Selection.setRange(range);
Syntax
Editor.Selection .setRange (range : XopusRange)
Arguments
- range
-
XopusRange. An XopusRange object.