跳到主要内容

MoveCursorLeft

向左移动光标。

语法

expression.MoveCursorLeft(count, addToSelect, byWords);

expression - 表示 ApiDocument 类的变量。

参数

名称必需/可选数据类型默认值描述
count可选number1移动次数。
addToSelect可选booleanfalse指定在移动过程中是否选择文本。
byWords可选booleanfalse指定是按单词移动还是按字符移动。

返回值

boolean

示例

此示例展示如何在文档中向左移动光标。

// How to move the cursor left by a specified number of characters.

// Add text, move cursor right, then move it left.
let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
paragraph.AddText("This is the text in your document.");
doc.MoveCursorToEnd();
doc.MoveCursorLeft(11);

paragraph = Api.CreateParagraph();
paragraph.AddText(doc.GetCurrentWord());
doc.Push(paragraph);