2 Replies Latest reply on Jan 5, 2017 3:21 AM by jakec88782761

    adding a menu action

    jakec88782761 Level 1

      Hi all,

       

      I'm trying to add a menu item with an onInvoke event listener.

      I'd like my menu to invoke a script using the doScript method.

      However, when I run it, it doesn't create my menu item.

       

      Any advice here?

       

      #include "C:/Users/jcahill/AppData/Roaming/Adobe/InDesign/Version 12.0/en_GB/Scripts/Scripts Panel/import idml translations.jsx"
      #targetengine "session"
      var m = app.menus.item( "$ID/Main" ).submenus.item( "Import translations" );

      m.isValid&&m.remove();

      var addCustomMenu = (function () {
         
          var customMenuAction = app.scriptMenuActions.add( "Choose IDML files" );
         
          var customMenu = app.menus.item( "$ID/Main" ).submenus.item( "Import translations" );
         
          var customMenuItem;
         
          if ( !customMenu.isValid ) {
             
              customMenu = app.menus.item( "$ID/Main" ).submenus.add( "Import translations" );
              customMenuItem = customMenu.menuItems.item( "Choose IDML files" );
             
              }
          var u;
         var f =  function  () {
             
              app.doScript( "import idml translations.jsx", u,u,UndoModes.ENTIRE_SCRIPT, "Import IDML files" );
             
              }
         
          var el = customMenuAction.eventListeners.add( "onInvoke", f, false );
          if ( !customMenuItem.isValid ) {
             
              customMenu.menuItems.add( customMenuAction );
             
              }
         
          }());