跳到主要内容

MoveCursorToPos

将光标移动到当前文档的指定位置。 如果文档中有任何选区,将被移除。

语法

expression.MoveCursorToPos(nPos);

expression - 表示 ApiDocument 类的变量。

参数

名称必需/可选数据类型默认值描述
nPos可选number0所需的光标位置。

返回值

boolean

示例

此示例将光标移动到范围对象内的指定位置。

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