Unselect
从选择中移除当前图形对象。
语法
expression.Unselect();
expression - 表示 ApiDrawing 类的变量。
参数
此方法没有任何参数。
返回值
boolean
示例
在 PDF 表单的页面上从当前选区中移除一个形状,同时保持其他形状处于选中状态。
// Deselect a single drawing without clearing the whole multi-shape selection.
// Create three shapes, select all of them, then unselect the second one so the first and third stay selected.
const doc = Api.GetDocument();
const page = doc.GetPage(0);
const fill1 = Api.CreateSolidFill(Api.RGB(255, 111, 61));
const stroke1 = Api.CreateStroke(0, Api.CreateNoFill());
const drawing1 = Api.CreateShape("rect", 60 * 36000, 35 * 36000, fill1, stroke1);
page.AddObject(drawing1);
drawing1.SetPosition(0, 0);
const fill2 = Api.CreateSolidFill(Api.RGB(51, 133, 255));
const stroke2 = Api.CreateStroke(0, Api.CreateNoFill());
const drawing2 = Api.CreateShape("rect", 60 * 36000, 35 * 36000, fill2, stroke2);
page.AddObject(drawing2);
drawing2.SetPosition(70 * 36000, 0);
const fill3 = Api.CreateSolidFill(Api.RGB(61, 255, 111));
const stroke3 = Api.CreateStroke(0, Api.CreateNoFill());
const drawing3 = Api.CreateShape("rect", 60 * 36000, 35 * 36000, fill3, stroke3);
page.AddObject(drawing3);
drawing3.SetPosition(140 * 36000, 0);
drawing1.Select(true);
drawing2.Select();
drawing3.Select();
drawing2.Unselect();