Editor.Selection.setRange
Change the selection in the Editor to the supplied range.
First, obtain a XopusRange 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);
- Documentation
- › API
- › Global objects API
- › Editor.Selection.setRange
Editor.Selection.setRange( range : XopusRange)
: XopusRange)Arguments
- range
- XopusRange. An XopusRange object.