10
Modifying the User Interface
Using Adobe Dialog Manager (ADM) in Acrobat JavaScript
The following
initialize
handler initializes the items used in the
list_box.
Note that it
receives the
dialog
object as a parameter:
// Event handler to initialize the list_box
initialize: function(dialog)
{
// Create a list_box named sub1 and set up 4 choices:
dialog.load({
"sub1":
{
"one": -1,
"two": -2,
"three": +3,
"four": -4
}
});
}
The following
commit
handler is called when
OK
is clicked, retrieves the values of the
items used in the
list_box
, and can take action based on those values. Note that it
receives the
dialog
object as a parameter:
commit: function(dialog)
{
// Retrieve the values stored in list_box sub1:
var elements = dialog.store()["sub1"];
// Iterate through items and take actions as needed
for (var e in elements)
{
// perform action
}
}
It is also possible to write event handlers for specific items selected in the dialog. The
following handler is called when the button labeled
butn
is clicked:
"butn": function(dialog)
{
app.alert("butn was clicked.");
}
Finally, to create the root node, we must create the
description
object literal, which is
the
dialog
descriptor. This is shown in the complete sample code shown below:
166
Acrobat JavaScript Scripting Guide