Skip to main content

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

NameRequired/OptionalData typeDefaultDescription
nPosOptionalnumber0The desired cursor position.

Returns

boolean

Example

This example moves cursor to a specified position inside the range object.

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());