Menus. Adobe InCopy CS6

Add to My manuals
105 Pages

advertisement

Menus. Adobe InCopy CS6 | Manualzz

6

Menus

CS6

Chapter Update Status

Unchanged

InCopy scripting can add menu items, remove menu items, perform any menu command, and attach scripts to menu items.

This chapter shows how to work with InCopy menu scripting. The sample scripts in this chapter are presented in order of complexity, starting with very simple scripts and building toward more complex operations.

We assume that you have read Chapter 2, “Getting Started”

and know how to create, install, and run a script.

Understanding the menu model

The InCopy menu-scripting model is made up of a series of objects that correspond to the menus you see in the application’s user interface, including menus associated with panels as well as those displayed on the main menu bar. A menu object contains the following objects:

 menuItems

— The menu options shown on a menu. This does not include submenus.

 menuSeparators

— Lines used to separate menu options on a menu.

 submenus

— Menu options that contain further menu choices.

 menuElements — All menuItems , menuSeparators and submenus shown on a menu.

 eventListeners — These respond to user (or script) actions related to a menu.

 events

— The events

triggered by a menu.

Every menuItem

is connected to a menuAction

through the associatedMenuAction

property. The properties of the menuAction

define what happens when the menu item is chosen. In addition to the menuActions

defined by the user interface, InCopy scripters can create their own, scriptMenuActions

, which associate a script with a menu selection.

A menuAction or scriptMenuAction can be connected to zero, one, or more menuItems .

The following diagram shows how the different menu objects relate to each other:

68

Menus Understanding the menu model 69 application menuActions menuAction area checked enabled eventListeners id index label name events parent title scriptMenuActions scriptMenuAction same as menuAction eventListener eventListener

...

event event

...

To create a list (as a text file) of all visible menu actions, run the following script fragment (from the

GetMenuActions tutorial script): var myMenuActionNames = app.menuActions.everyItem().name;

//Open a new text file.

var myTextFile = File.saveDialog("Save Menu Action Names As", undefined);

//If the user clicked the Cancel button, the result is null.

if(myTextFile != null){

//Open the file with write access.

myTextFile.open("w"); for(var myCounter = 0; myCounter < myMenuActionNames.length; myCounter++){ myTextFile.writeln(myMenuActionNames[myCounter]);

} myTextFile.close();

}

To create a list (as a text file) of all available menus, run the following script fragment (for the complete script listing, refer to the GetMenuNames tutorial script). Note that these scripts can be very slow, as there are a large number of menu names in InCopy.

advertisement

Related manuals

Download PDF

advertisement

Table of contents