跳到主要内容

SelectCurrentSentence

选择光标处的句子。如果存在当前文本选区,则会先将其移除。

语法​

expression.SelectCurrentSentence();

expression - 表示 ApiPresentation 类的变量。

参数​

此方法没有任何参数。

返回值​

boolean

示例​

在演示文稿中选中光标处的句子。

// How do I select a whole sentence from the cursor position in a presentation?

// Place the cursor inside the second sentence of a shape, select the sentence and make it bold in a presentation.

const presentation = Api.GetPresentation();
const slide = presentation.GetSlideByIndex(0);
slide.RemoveAllObjects();

const fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
const stroke = Api.CreateStroke(0, Api.CreateNoFill());
const shape = Api.CreateShape("rect", 300 * 36000, 130 * 36000, fill, stroke);
shape.SetPosition(608400, 1267200);
slide.AddObject(shape);

shape.GetTextRange().SetText("Slides tell a story. Every slide makes one point. Keep the text short.");
shape.GetTextRange().MoveCursorToPos(25);

presentation.SelectCurrentSentence();
Api.GetSelection().GetTextRange().SetBold(true);