跳到主要内容

MoveCursorToPos

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

语法

expression.MoveCursorToPos(nPos);

expression - 表示 ApiRange 类的变量。

参数

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

返回值

boolean

示例

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

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This text for time field");
let range = paragraph.GetRange();
range.MoveCursorToPos(range.GetEndPos());
paragraph = Api.CreateParagraph();
paragraph.AddText("The cursor was moved to the end of range");
doc.Push(paragraph);