Adobe 65009333 - InCopy CS4 - PC Manual page 74

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

Advertisement

Events
afterOpen
document.
eventListeners
in every InCopy session, add the script to the startup scripts folder (for more on installing scripts, see
Chapter 2, "Getting
the document or exported to INX.
N
: If you are having trouble with a script that defines an
OTE
that removes the
eventListeners
use
#targetengine "session"
function is not available when the event occurs, and the script generates an error.
An event can trigger multiple
following sample script demonstrates an event triggering
(for the full script, see MultipleEventListeners):
#targetengine "session"
main();
function main(){
var myApplicationEventListener = app.eventListeners.add("beforeImport",
myEventInfo, false);
var myDocumentEventListener = app.documents.item(0).eventListeners.add
("beforeImport", myEventInfo, false);
}
function myEventInfo(myEvent){
var myString = "Current Target: " + myEvent.currentTarget.name;
alert(myString);
}
When you run the above script and place a file, InCopy displays alerts showing, in sequence, the name of
the document, then the name of the application.
The following sample script creates an
about the event in a simple dialog box. For the complete script, see EventListenersOn.
main()
function main(){
app.scriptPreferences.version = 5.0;
var myEventNames = [
"beforeQuit", "afterQuit",
"beforeNew", "afterNew",
"beforeOpen", "afterOpen",
"beforeClose", "afterClose",
"beforeSave", "afterSave",
"beforeSaveAs", "afterSaveAs",
"beforeSaveACopy", "afterSaveACopy",
"beforeRevert", "afterRevert",
"beforePrint", "afterPrint",
"beforeExport", "afterExport",
"beforeImport", "afterImport"
] ;
for (var myCounter = 0; myCounter < myEventNames.length; myCounter ++){
app.addEventListener(myEventNames[myCounter], myEventInfo, false);
}
}
event can be observed by
do not persist beyond the current InCopy session. To make an
Started."). When you add an
or quit and restart InCopy.
eventListener
that use handler functions defined inside the script (rather than in an external file) must
. If the script is run using
eventListeners
associated with both the application and the
eventListeners
eventListener
eventListener
#targetengine "main"
as it propagates through the scripting object model. The
eventListeners
for each supported event and displays information
eventListener
Working with eventListeners 74
eventListener
script to a document, it is not saved with
, you can either run a script
(the default), the
registered to different objects
available

Advertisement

Table of Contents
loading

This manual is also suitable for:

Incopy cs4

Table of Contents