MoveCursorToPos
Moves a cursor to a specified position of the current document. If there is any selection in the document, it will be removed.
Syntax
expression.MoveCursorToPos(nPos);
expression
- A variable that represents a ApiDocument class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
nPos | Optional | number | 0 | The desired cursor position. |
Returns
boolean
Example
This example moves cursor to a specified position inside the range object.
- Code
- Result
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is the text in your document.");
paragraph = Api.CreateParagraph();
paragraph.AddText("The cursor was moved to the end of the document");
doc.Push(paragraph);
let range = doc.GetRange();
doc.MoveCursorToPos(range.GetEndPos());