跳到主要内容

SetLabel

为按钮控件字段设置标签。

语法

expression.SetLabel(label, appearance);

expression - 表示 ApiButtonWidget 类的变量。

参数

名称必需/可选数据类型默认值描述
label必需string按钮标签。
appearance可选ButtonAppearance"normal"外观状态。

返回值

boolean

示例

在 PDF 文档中设置按钮控件的标签。

// Configure labels for different button states: normal, down, and hover.

// Apply multiple labels to a button widget with 'push' behavior.

let doc = Api.GetDocument();
let page = doc.GetPage(0);
let buttonField = Api.CreateImageField([10, 10, 120, 100]);
page.AddObject(buttonField);

let widgets = buttonField.GetAllWidgets();
widgets[0].SetLayout('iconTextV');
widgets[0].SetBehavior('push');

widgets[0].SetLabel('Normal label', 'normal');
widgets[0].SetLabel('Down label', 'down');
widgets[0].SetLabel('Hover label', 'hover');