Skip navigation
Currently Being Moderated

Extensions without (visible) UI?

Jan 11, 2012 6:41 PM

Tags: #indesign #extension #manifest #events #cssdk

Hi all,


Question: is it possible to have extensions without a UI, or with an optional UI? I've managed to come close to getting this to work, but it seems to remain just beyond my grasp. This is using InDesign.


What I want to achieve:I want the extension to run at all times so it can listen for documentAfterSave events even when the panel is not showing, and I want to have the 'panel visible' state persist across user sessions.


The first thing was to get the extension to load on app startup.


In the Lifecycle panel in the manifest editor, I unchecked 'AutoVisible' (not sure whether that was important)

Then I added the applicationActivate event to the list of 'StartOn' events.


That makes my extension shows up when the app starts. Cool.


But I want to be in control of the panel visibility - i.e. if the user had the panel hidden when he last used the app, I want the extension to be hidden when the user launches the app at a later time.


I.e. I want to save the 'visible' state for the extension panel between user sessions. I tried saving and restoring the visible state via the CSXSInterface.instance.whatchamacallit stuff, and I tried listening for state change events for WINDOW_SHOW and WINDOW_HIDE, so I could keep track and safeguard the panel's visibility state, but it looks like those events don't really work (see Harb's bug list elsewhere on this forum). I also tried moving the panel off-screen to simulate being hidden (old trick, didn't work).


Before I give up and try a different approach (without extension builder), does anyone know whether this can be made to work?


Another lingering doubt: suppose I got it to work, how good is the documentAfterSave event? For example, when the user closes an unsaved document, and then agrees to save the document when alerted ('Do you want to save...' dialog).


Will the event fire early enough so I can still extract information from the document before InDesign starts tearing down the document data structures? Or will I end up in the twilight zone, where merely accessing the half-disassembled document object can cause crashes? Or will I find the document has already been closed from before the event fired?





  • Currently Being Moderated
    Jan 11, 2012 10:58 PM   in reply to RorohikoKris

    To make an offscreen extension, make your extension type modeless and do something like this:


                   private function preinit():void{

                        var geo:WindowGeometry = new WindowGeometry();

                        geo.topleftx = -500;

                        CSXSInterface.getInstance().requestStateChange(Sta teChangeEvent.WINDOW_MOVE,geo);



    You'll get a quick flash of the dialog before it moves offscreen, but it's better than nothing...


    As far as documentAfterSave goes, I'd guess that you should be okay, but I'd test to be sure...



    Mark as:
  • Currently Being Moderated
    Jan 12, 2012 6:04 AM   in reply to RorohikoKris

    Hi Kris,



    AutoVisible=false means that when this extension is loaded its UI is not made visible, leaving that up to the extension. Generally, panels should have AutoVisible=true so that when a user selects the panel from the menu they can be assured that it will be made visible immediately, it also ensures correct behavior when the panel is docked or closed.



    So the question is how to fix your problem?



    I would suggest breaking this into two extensions, one extension that is a vanilla panel and another modeless extension which is hidden and sits waiting for events. The hidden one should start on applicationActivate, have AutoVisible=false, and not have a <Menu> element in its manifest (so it doesn't show up in Window > Extensions). This hidden extension can then respond to the save event, it can also activate your panel on first launch.



    Does that work for your use case?

    Mark as:
  • Currently Being Moderated
    Jan 12, 2012 6:12 AM   in reply to zak.nelson

    Thanks Zak,


    Useful stuff to know. I just tried AutoVisible=false on a modaless extension and it worked like a charm!


    Hope this is useful to Kris too...



    Mark as:
  • Currently Being Moderated
    Jan 12, 2012 12:10 PM   in reply to RorohikoKris

    RorohikoKris wrote:

    The two controllers would exchange stuff via CSXSEvents.


    You probably don't need CSXSEvents. All you need is a reference to the other extension and you can call public methods directly.




    Mark as:
  • Currently Being Moderated
    Jul 27, 2012 3:11 PM   in reply to zak.nelson

    A couple questions on how to have an invisible ui.  Are there any update for getting this to work in 3.0?


    It seems like AutoVisible=false doesn't work when using a CSExtension, but does when using mx.core.Application.  Everything else seems to work find with mx:Application, except for being able to clean up.  I have a server socket I need to close for Photoshop to exit cleanly, but I can't find any hook that'll let me both have an invisible extension and have a chance to cleanup.


    I've tried going through PSEventAdapter, and various events on the Application, but haven't found anything yet.


    Any ideas?



    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (1)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points