5 Replies Latest reply on Mar 24, 2010 2:31 PM by Steven..

    javascript - menuAction

    Steven.. Level 3

      Is there a way to invoke a menuAction and wait until user has finished filling in resulting dialogs and actions are complete before continuing with script?

      APID?

        • 1. Re: javascript - menuAction
          Harbs. Level 6

          Depends what you're doing...

           

          Harbs

          1 person found this helpful
          • 2. Re: javascript - menuAction
            Steven.. Level 3

            The reason this is impossible, is because the menu action opens the dialog and the dialog is not accessible until the script completes it work. Only then does the dialog become available for work. In the past I have been able to work around this when calling menuaction from external application through com or applescript, which doesn't run in the same thread as InDesign application, allowing modal dialog to be active and the loop in external application to wait until dialog has been dismissed.

            • 3. Re: javascript - menuAction
              John Hawkinson Level 5

              That doesn't make it impossible. You can, for instance, #targetengine session and attach an event handler to the afterInvoke event associated with the modal dialogue. Then all your work happens in the event handler. This kind of event-driven programming can be more tricky, but doable.

              • 4. Re: javascript - menuAction
                Steven.. Level 3

                True, but it won't work in my situation where the menu action is part of a loop, which needs to complete after the dialog has closed. This would probably require serious restructuring of the script.

                Another thing, I'm not sure that afterInvoke will work with invoked dialogs, because the action has already completed its job. Its job is to bring up the dialog. The dialog contains its own set of instruction how to react to the users actions, but is totally disconnected to the action. But I guess I can try when I get a chance.

                • 5. Re: javascript - menuAction
                  Harbs. Level 6

                  With commands like print(), the script does wait until the dialog is dismissed. It

                  could be you are right about afterInvoke being befor ethe dialog is displayed. maybe sleep() would help? Or a BridgeTalk invoked sleep?

                   

                  Gotta check this out...

                   

                  Harbs