Skip to content

Support a mouse-up JavaScript action on form fields (onClick option) #1792

Description

@KaiPressmar

Following the invitation in `docs/forms.md`'s Advanced Form Field Use section: "If an option is not supported, open an issue on Github and it will be considered for addition to the API."

The gap

There's no supported way to attach a mouse-up JavaScript action to a form field — most usefully, a push button that runs custom logic when clicked. The only code path that ever reaches `AA` is `mapFormat()`, and only together with a `format` option, which is meant for keystroke/format validation, not arbitrary actions. Any other use of `AA` is silently dropped with no error.

This came up building an interactive PDF with clickable push buttons that toggle state via a mouse-up action.

Proposed addition

An `onClick` option, accepted by all form annotation methods, mapping to the field's `AA.U` mouse-up action — accepting either a plain string or a function (stringified into the action, called with Acrobat's own `app`/`getField`/`display`/`event` as arguments and `this` bound to the Document).

I have a working implementation with tests, docs, and a small opt-in TypeScript types file for the handful of Acrobat globals the option's function form needs — see #1790.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions