Working With Script Menu Actions - Adobe 65009333 - InCopy CS4 - PC Manual

Scripting guide: javascript
Hide thumbs Also See for 65009333 - InCopy CS4 - PC:
Table of Contents

Advertisement

Menus

Working with script menu actions

You can use
script registered to run when the
The following script shows how to create a
complete script, see MakeScriptMenuAction). This script simply displays an alert when the menu item is
selected.
var mySampleScriptAction = app.scriptMenuActions.add("Display Message");
var myEventListener = mySampleScriptAction.eventListeners.add("onInvoke",
function(){alert("This menu item was added by a script.");});
//If the submenu "Script Menu Action" does not already exist, create it.
try{
var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.item(
"Script Menu Action");
mySampleScriptMenu.title;
}
catch (myError){
var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.add
("Script Menu Action");
}
var mySampleScriptMenuItem = mySampleScriptMenu.menuItems.add(mySampleScriptAction);
To remove the
following script fragment (from the RemoveScriptMenuAction tutorial script):
#targetengine "session"
var mySampleScriptAction = app.scriptMenuActions.item("Display Message");
mySampleScriptAction.remove();
var mySampleScriptMenu = app.menus.item("$ID/Main").submenus.item
("Script Menu Action");
mySampleScriptMenu.remove();
You also can remove all
RemoveAllScriptMenuActions tutorial script). This script also removes the menu listings of the
scriptMenuAction
#targetengine "session"
app.scriptMenuActions.everyItem().remove();
You can create a list of all current
the GetScriptMenuActions tutorial script):
var myScriptMenuActionNames = app.scriptMenuActions.everyItem().name;
//Open a new text file.
var myTextFile = File.saveDialog("Save Script 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 < myScriptMenuActionNames.length; myCounter++){
myTextFile.writeln(myScriptMenuActionNames[myCounter]);
}
myTextFile.close();
}
scriptMenuAction
executed before an internal request for the state of the
to create a new
scriptMenuAction
onInvoke event
,
,
menu
submenu
menuItem
scriptMenuAction
, but it does not delete any menus or submenus you might have created.
scriptMenuActions
also can run scripts during their
whose behavior is implemented through the
menuAction
is triggered.
scriptMenuAction
, and
scriptMenuAction
, as shown in the following script fragment (from the
, as shown in the following script fragment (from
beforeDisplay event
scriptMenuAction
Working with script menu actions 68
and attach it to a menu item (for the
created by the above script, run the
, in which case they are
(e.g., when the menu item is

Advertisement

Table of Contents
loading

This manual is also suitable for:

Incopy cs4

Table of Contents