Popup Menu Programming in Acrobat JavaScript

The popup menu is one the most useful and easy to use User Interface Items available to the Acrobat JavaScript programmer. Unlike many of the other UI options (buttons, edit fields, lists, etc.) it can be used in Folder level scripts as well as at the Document level and lower. Document level scripting is primarily used for forms related operations and document navigation, and for this use Acrobat provides a rich set of UI elements that have been well covered in the industry literature. Folder level scripting on the other hand, is primarily used to either automate tasks in Acrobat or to provide general utility functions for other scripts. There are relatively few UI elements available to the JS programmer at the folder level, making the popup menu even more valuable for this purpose.

If you develop folder level scripts using popup menus there are a couple of things you need to be aware of. First, a popup menu will only appear on top of a document window, no open documents means no menu. Second, Acrobat tries to place the menu at the last cursor location, or as close as it can get to it. You will have to watch carefully to see where the menu ‘pops up.’ It may actually appear somewhere around the edge of the document window. Debugging folder level scripts is also a bit troublesome since Acrobat has to be restarted every time the script is changed.

Acrobat JavaScript provides 2 methods for creating popup menus, app.popUpMenu (introduced in Acrobat 5.0), and app.popUpMenuEx (introduced in Acrobat 6.0). Both of these methods are very similar in how they operate. The newer method, popUpMenuEx, is slightly more complex, but offers a variety of useful options.

You May Also Like

About the Author: Thom Parker

Leave a Reply