0 Replies Latest reply on Feb 24, 2011 9:43 PM by IDRaj

    Invoke Method to PopUp Pallete...

    IDRaj

      I am new to InDesign Scripting....

       

      I want to add a menu on rightclick to new popup pallete and I have used the method menuscritp.invoke(); As per my requirement the popup appears and when i use rightclick the popup disappear, Please anyone help me out that popup should not disappear...

       

      My Script is...

       

      #targetengine "session"
      main();
      function main()
      {
      mySetup();
      mySnippet();
          myTeardown();
      }

      function mySetup(){}

      function mySnippet()
      {
      var myLayoutContextMenu = app.menus.item("$ID/RtMouseLayout");
          var myBeforeDisplayListener = myLayoutContextMenu.addEventListener("beforeDisplay", myBeforeDisplayHandler, false);
      }

      function myTeardown(){}

      function myBeforeDisplayHandler(myEvent)
      {
          var myLayoutContextMenu = app.menus.item("$ID/RtMouseLayout");
          if(myCheckForMenuItem(myLayoutContextMenu, "New Menu") == false)
          {
              myMakeLabelGraphicMenuItem();
          }
      }
       
      function myMakeLabelGraphicMenuItem()
      {
          if(myCheckForScriptMenuItem("New Menu") == false)
          {
              var myLabelGraphicMenuAction = app.scriptMenuActions.add("New Menu");
              var myLabelGraphicEventListener = myLabelGraphicMenuAction.eventListeners.add("onInvoke", myLabelGraphicEventHandler);
          }
         else
         {
              var myLabelGraphicMenuAction = app.scriptMenuActions.add("New Menu");
              var myLabelGraphicEventListener = myLabelGraphicMenuAction.eventListeners.add("onInvoke", myLabelGraphicEventHandler);
             }
          var myLabelGraphicMenuItem = app.menus.item("$ID/RtMouseLayout").menuItems.add(app.scriptMenuActions.item("New Menu"));

          function myLabelGraphicEventHandler(myEvent)
          {
              try
              {
                  var viewAlternative;
                  var viewAlternative = app.menuActions.item("Menu");
                  viewAlternative.invoke();
              }
              catch(myError)
              {
                  alert("Please add the Menu Panels to the PlugIns Folder and Restart Application!!!");
              }
          }
      }

      function myCheckForMenuItem(myMenu, myString)
      {
          var myResult = false;
          try
          {
              var myMenuItem = myMenu.menuItems.item(myString);
              myMenuItem.name;
              myResult = true
          }
          catch(myError){}
          return myResult;
      }

      function myCheckForScriptMenuItem(myString)
      {
          var myResult = false;
          try
          {
              var myScriptMenuAction = app.scriptMenuActions.item(myString);
              myScriptMenuAction.name;
              myResult = true
          }
          catch(myError){}
          return myResult;  
      }