In the Adobe InDesign CS6 Scripting Guide: JavaScript (link to pdf), in Chapter 8: Events on page 136 it says,
eventListeners
that use handler functions defined inside the script (rather than in an external file) must use#targetengine "session"
. If the script is run using#targetengine "main"
(the default), the function is not available when the event occurs, and the script generates an error.
The error looks like this:
The requested action could not be completed because the object no longer exists.
Using a #targetengine
is not an option for my script, so I'm stuck with using an external file reference for the event handler.
My problem is this: how do I access the event object in the external file event handler? I've tried app.scriptArgs.get("event")
and checking typeof event
to no avail. My event handler is useless without knowing the target of the event.