2 Replies Latest reply on Jun 29, 2010 8:39 AM by richardh6

    [JS] Basic question about event listeners and event handlers

    richardh6 Level 1

      I am very new to the whole topic of event listeners and event handlers.  I'd run the test for the following problem myself, but I don't know where to start, and I just want to know if it's impossible -- that is, if I'm misunderstanding what event listeners and event handlers do.


      Say I have an InDesign document with a text frame that is linked to an InCopy story.  Can I use an "afterImport" event listener on the text frame to perform some action any time the link to the InCopy story gets updated?  And will the event handler have access to both the story that is imported, and the pathname of the InCopy file?



        • 1. Re: [JS] Basic question about event listeners and event handlers
          Kasyan Servetsky Level 5

          afterImport event is triggered after you place something into your document: an image, a text file, etc. So that's not what you need in this case.

          BTW, you don't mention which version you use. CS5 has many new events, but I hasn't studied them yet -- in the scripting reference I found the following:

          AFTER_LINKS_CHANGED -- Dispatched after one or more links in the Event have been added, deleted, or  modified. This event bubbles. This event is not cancelable. (default:  afterLinksChanged)


          Probably you can use it for your script --  I can't check this at the moment.


          If you are on CS3/4 you can write a script that runs at certain intervals in the background and triggers another script that loops thru all links in the document and if a link is modified and its type is incopy file, do something to it.



          2 people found this helpful
          • 2. Re: [JS] Basic question about event listeners and event handlers
            richardh6 Level 1

            Thank you, Kasyan.


            Both of those are good solutions.


            We are currently using InDesign CS4 and InCopy CS5.  I'm hoping to get them to purchase the whole CS5 suite soon, since I'd like to start writing scripts for InDesign CS5 as soon as possible, as long as I'm going to have to be doing it in the not too distant future anyway.  The greater variety of event handlers sounds like it might be something that is crucial to the project I'm working on, so that adds to the argument for getting CS5.


            Thanks again.  You have no idea how helpful this is.  I made some promises to my boss yesterday that I later realized were  based on assumptions of mine about the InDesign/InCopy system that didn't make any sense, and I was going  to have to retract my promises.  But after reading your response I think I can still deliver, in a slightly different way that I had been thinking before.