MoveCursorToPos

function MoveCursorToPos(nPos: number = 0): boolean

Description

Move cursor to a specified position of the current text run. If the current run is not assigned to any part of the document then returns false otherwise returns true. If there was any selection in the document, it will be removed.

Parameters

nPosnumberdefault: 0

Desired cursor position.

Returns

boolean

Try It

let oDocument = Api.GetDocument();
let oPara = oDocument.GetElement(0);
let oRun = oPara.AddText("The quick brown fox jumps over the lazy dog");
oRun.MoveCursorToPos(16);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).