3 Replies Latest reply on Jan 4, 2011 3:42 PM by Olav Martin Kvern

    Why is IDScriptingEventAdapter.getInstance().addEventListenerToObject Not Working

    mlavie Level 1

      I can not seem to get IDScriptingEventAdapter.getInstance().addEventListenerToObject to work in ActionScript in InDesign CS5.

       

      I wrote the following (looping through all PageItem's in the Page, as well as running the same methods for the page itself):

       

           for each (var pageItem:PageItem in page.allPageItems)

           {

            adapter.addEventListenerToObject(MutationEvent.AFTER_ATTRIBUTE_CHANGED, listener, pageItem);
            adapter.addEventListenerToObject(com.adobe.indesign.Event.AFTER_SELECTION_ATTRIBUTE_CHANG ED, listener, pageItem);
            adapter.addEventListenerToObject(com.adobe.indesign.Event.AFTER_SELECTION_CHANGED, listener, pageItem);
            adapter.addEventListenerToObject(com.adobe.indesign.Event.AFTER_MOVE, listener, pageItem);
            adapter.addEventListenerToObject(com.adobe.indesign.Event.BEFORE_MOVE, listener, pageItem);
            adapter.addEventListenerToObject(com.adobe.indesign.Event.AFTER_DELETE, listener, pageItem);
            adapter.addEventListenerToObject(com.adobe.indesign.Event.BEFORE_DELETE, listener, pageItem);

           }

       

      Yet no matter what I do (move/delete/create/resize/copy/paste) to the PageItem's on the Page - no event is captured. What am I doing wrong?

       

      BTW - If I do:

       

           adapter.addEventListener(MutationEvent.AFTER_ATTRIBUTE_CHANGED, listener);
           adapter.addEventListener(com.adobe.indesign.Event.AFTER_SELECTION_ATTRIBUTE_CHANGED, listener);
           adapter.addEventListener(com.adobe.indesign.Event.AFTER_SELECTION_CHANGED, listener);
           adapter.addEventListener(com.adobe.indesign.Event.AFTER_MOVE, listener);
           adapter.addEventListener(com.adobe.indesign.Event.BEFORE_MOVE, listener);
           adapter.addEventListener(com.adobe.indesign.Event.AFTER_DELETE, listener);
           adapter.addEventListener(com.adobe.indesign.Event.BEFORE_DELETE, listener);

      then app level events are caught.

       

      TIA - mlavie