6 Replies Latest reply on Jul 28, 2010 1:36 PM by lanejd

    JS: Persistent Modeless Dialog

    lanejd

      I am trying to make a modeless dialog box for InDesign, but for some reason the dialog always closes after the script runs (i.e. I see the dialog for a brief second until the script finishes running, then it's gone). I cannot get it to persist. I need to be able to edit a document while the dialog is open. Any suggestions?

       

      I am using the ScriptUI classes to create a dialog with the property 'palette'.

        • 1. Re: JS: Persistent Modeless Dialog
          Kasyan Servetsky Level 5

          Run it in a persistent engine -- e.g.

          #targetengine "session"

          1 person found this helpful
          • 2. Re: JS: Persistent Modeless Dialog
            lanejd Level 1

            I tried that, still the same. I can put that at the beginning of the script, right? Along with my application target?

             

             

            Example:

             

            #target InDesign

            #targetengine "session"

             

            Here is my whole script (don't laugh too hard, I am still trying to figure this out ):

             

            #target InDesign
            #targetengine "session"
            
            function closeWindow(){
                 posWin.close();
                 };
            
            var posWin = new Window(
                 'palette',
                 'Position the Image',
                 undefined, {
                      resizable: false,
                      closeButton: true,
                      maximizeButton: false,
                      minimizeButton: false,
                      independent: false,
                      borderless: true
                 });
            posWin.location = [0, 0];
            posWin.info = posWin.add('panel', undefined, undefined);
            posWin.action = posWin.add('panel', undefined, undefined);
            posWin.action.orientation = 'row';
            
            posWin.action.prevMaterialBtn = posWin.action.add('button', undefined, '<-- Previous Material');
            posWin.action.cancelBtn = posWin.action.add('button', undefined, 'Cancel');
            posWin.action.cancelBtn.onClick = closeWindow;
            posWin.action.nextMaterialBtn = posWin.action.add('button', undefined, 'Next Material -->');
            
            // This function will call an instance of a template, delete the link to the current photo, replace it with a new photo and then wait for an onClick (or some other) event. 
            // It will then write the information to the XMP, close the template and open the next template.
            
            posWin.show();
            

            • 3. Re: JS: Persistent Modeless Dialog
              Kasyan Servetsky Level 5

              Your code works for me: the window stays open at the top left corner of my monitor until I click Cancel.

              • 4. Re: JS: Persistent Modeless Dialog
                Peter Kahrel Adobe Community Professional & MVP

                Are you running this script from the ESTK? In Windows, using CS3 or CS4, you need to run your script once from the scripts panel. After that you can run it from the ESTK.

                 

                Peter

                1 person found this helpful
                • 5. Re: JS: Persistent Modeless Dialog
                  Marijan Tompa [tomaxxi] Level 4

                  Hey!

                   

                  I think you can run it from ESKT, but you need to link it to InDesign not to ESKT.

                  There is little dropdown in ESKT where you can select destination app.

                   

                  tomaxxi

                  • 6. Re: JS: Persistent Modeless Dialog
                    lanejd Level 1

                    You were right on the money, Peter! I didn't know about that. This answered the real question for me. I am sorry I had already posted the question being answered before you posted you're reply, I would have given you credit for the correct answer. This is a great tip. It will save me an immeasurable amount of time and headaches. Thanks!