class HexaPDF::Type::AcroForm::ButtonField

Parent

AcroForm button fields represent interactive controls to be used with the mouse.

They are divided into push buttons (things to click on), check boxes and radio buttons. All of these are represented with this class.

To create a push button, check box or radio button field, use the appropriate convenience methods on the main Form instance (HexaPDF::Document#acro_form). By using those methods, everything needed is automatically set up.

Type Specific Field Flags

:no_toggle_to_off

Only used with radio buttons fields. If this flag is set, one button needs to be selected at all times. Otherwise, clicking on the selected button deselects it.

:radio

If this flag is set, the field is a set of radio buttons. Otherwise it is a check box. Additionally, the :pushbutton flag needs to be clear.

:push_button

The field represents a pushbutton without a permanent value.

:radios_in_unison

A group of radio buttons with the same value for the on state will turn on or off in unison.

See: PDF1.7 s12.7.4.2

Constants

FLAGS_BIT_MAPPING

Updated list of field flags.

INHERITABLE_FIELDS

All inheritable dictionary fields for button fields.

Public Instance Methods

check_box?()

Returns true if this button field represents a check box.

check_box_on_name()

Returns the name (a Symbol) used for setting the check box to the on state.

Defaults to :Yes if no other name could be determined.

concrete_field_type()

Returns the concrete button field type, either :push_button, :check_box or :radio_button.

create_appearances()

Creates appropriate appearances for all widgets if they don't already exist.

The created appearance streams depend on the actual type of the button field. See AppearanceGenerator for the details.

create_widget(page, defaults: true, value: nil, **values)

Creates a widget for the button field.

If defaults is true, then default values will be set on the widget so that it uses a default appearance.

If the widget is created for a radio button field, the value argument needs to set to the value (a Symbol or an object responding to #to_sym) this widget represents. It can be used with field_value= to set this specific widget of the radio button set to on.

See: Field#create_widget, AppearanceGenerator button field methods

Calls superclass method
default_field_value()

Returns the default field value.

See: field_value

default_field_value=(value)

Sets the default field value.

See: field_value=

field_value()

Returns the field value which depends on the concrete type.

Push buttons

They don't have a value, so nil is always returned.

Check boxes

For check boxes that are in the on state the value true is returned. Otherwise false is returned.

Radio buttons

If no radio button is selected, nil is returned. Otherwise the value (a Symbol) of the specific radio button that is selected is returned.

field_value=(value)

Sets the field value which depends on the concrete type.

Push buttons

Since push buttons don't store any value, the given value is ignored and nothing is stored for them (e.g a no-op).

Check boxes

Use true for checking the box, i.e. toggling it to the on state, and false for unchecking it.

Radio buttons

To turn all radio buttons off, provide nil as value. Otherwise provide the value (a Symbol or an object responding to #to_sym) of a radio button that should be turned on.

initialize_as_check_box()

Initializes the button field to be a check box.

This method should only be called directly after creating a new button field because it doesn't completely reset the object.

initialize_as_push_button()

Initializes the button field to be a push button.

This method should only be called directly after creating a new button field because it doesn't completely reset the object.

initialize_as_radio_button()

Initializes the button field to be a radio button.

This method should only be called directly after creating a new button field because it doesn't completely reset the object.

push_button?()

Returns true if this button field represents a push button.

radio_button?()

Returns true if this button field represents a radio button set.

radio_button_values()

Returns the array of Symbol values that can be used for the field value of the radio button.

update_widgets()

Updates the widgets so that they reflect the current field value.