Select
在编辑器中选择文本范围。
语法
expression.Select();
expression - 表示 ApiTextRange 类的变量。
参数
此方法没有任何参数。
返回值
boolean
示例
在演示文稿编辑器中选择范围所涵盖的文本。
// Useful for highlighting a range for the user to see in the editor view.
// Select the text range in the presentation editor view.
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);
const docContent = shape.GetDocContent();
const paragraph = docContent.GetElement(0);
paragraph.AddText("This text will be selected programmatically.");
slide.AddObject(shape);
const range = shape.GetTextRange();
range.Select();