SetLabel
Sets label to button widget field.
Syntax
expression.SetLabel(label, appearance);
expression - A variable that represents a ApiButtonWidget class.
Parameters
| Name | Required/Optional | Data type | Default | Description |
|---|---|---|---|---|
| label | Required | string | The button label. | |
| appearance | Optional | ButtonAppearance | "normal" | The appearance state. |
Returns
boolean
Example
Set button widget labels in a PDF document.
// 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');