Modifying the User Interface
Adding Navigation to PDF Documents
10
Highlighting Form Fields and Navigational Components
You can use Acrobat JavaScript to customize the actions associated with buttons, links, and
bookmarks so that they change their appearance after the user has clicked on them.
For a button, which is a field, you can invoke its
highlight
property, which allows you to
specify how the button appears once it has been clicked. There are four choices, as shown
below in
Table 10.12:
T
ABLE
10.12
Button Appearance
Type
Keyword
none
invert
push
outline
highlight.n
highlight.i
highlight.p
highlight.o
For example, the following code makes the button appear pushed when clicked:
// set the highlight mode to push
var f = this.getField("myButton");
f.highlight = highlight.p;
As you learned earlier, the
link
object also has a
highlight
property.
There are other ways in which you can creatively address the issue of highlighting. For
example, you can change the background color of the button when clicked, by including a
line of code in the script passed into its
setAction
method. In the following example, the
button displays a greeting and changes its background color to blue when the mouse
enters its area:
var script = "app.alert('Hello!');";
script += "var myButton = this.getField('myButton');";
script += "myButton.fillColor = color.blue;";
f.setAction("MouseEnter", script);
This idea can be applied to the
bookMark
object’s
color
property, as well as the
link
object’s
borderColor
property. In both cases, similar code to that shown in the example
above can be used in the scripts passed into their
setAction
methods.
For
bookMark
objects, you may additionally consider changing the text or font style
through its
name
and
style
properties. For example, the following code adds the word
VISITED
to
myBookmark
and changes the font style to bold:
myBookmark.name += " - VISITED");
myBookmark.style = 2;
Acrobat JavaScript Scripting Guide
181