1 Reply Latest reply on Jun 29, 2010 9:42 AM by brettpolo

    [JS] Remove menu on quit?

    Pontus Uggla Level 1

      I have a script that creates a new menu item in the main menu with some menu items. After restarting the menu is still there but it is empty.

       

      Im looking for a way ro remove the menu completley, but from what ive understood there is no event Quit.

       

      How do I do this?

        • 1. Re: [JS] Remove menu on quit?
          brettpolo

          In CS5, it's pretty easy:

           

          if you create a menu:

          var testMenu = app.menus.item("$ID/Main").submenus.add("Test");
          

           

          you can add an event listener to the application to close the menu on quitting:

           

          var elCleanup = app.eventListeners.add("beforeQuit", function()
              {
                  testMenu.remove();
              })
          

           

           

          I don't think beforeQuit is avalable in ealier versions, so i'm not sure the best way to take care of this pre-CS5.

           

          I guess you could add a startup script along the lines of:

           

          try{
               app.menus.item("$ID/Main").submenus.item("Test").remove();
          }
          catch(e){}

           

          which would try to remove your menu every time InDesign starts up.

          1 person found this helpful