7 Replies Latest reply on May 3, 2016 1:26 AM by [Jongware]

    [JS] Expand the top menu

    K159 Level 1

      Hi.

       

      I want to expand the top menu using JavaScript.

       

      Is it possible?

       

      For example ...   Expand the file menu. 

      I want to make this state.

        • 1. Re: [JS] Expand the top menu
          [Jongware] Most Valuable Participant
          1 person found this helpful
          • 2. Re: [JS] Expand the top menu
            K159 Level 1

            Thanks for your comment.

             

            However, I don't know where refer to.

             

            I want to just expand menu.

             

             

            I tried these but not working...

            var mnu = app.menus.item("$ID/&File")
            mnu.invoke();
            
            var mnu = app.menus.item("$ID/Main").submenus.item("$ID/&File");
            mnu.invoke();
            

             

            Can you tell me in more detail?

            • 3. Re: [JS] Expand the top menu
              tpk1982 Level 4

              Hi.. i think invoke() is used to invoke the menu item already available

               

              for example, to invoke new document we can use

               

              app.scriptMenuActions.itemByID(257).invoke();

              • 4. Re: [JS] Expand the top menu
                K159 Level 1

                Hi.  I know it...

                 

                I want to expand the menu like picture..  not run menu.

                 

                Did I explained wrong?

                • 5. Re: [JS] Expand the top menu
                  tpk1982 Level 4

                  Did you tried Jongware provided link? I hope we can't call the existing menu.. may be thi will be useful for you

                   

                  Re: [JS] Menu Added via Scripting Moves

                  1 person found this helpful
                  • 6. Re: [JS] Expand the top menu
                    karthiks94217840 Level 2

                    Hi

                     

                    Try this

                     

                    //Start coding

                    #targetengine "FileManu"

                     

                    menuInstaller(); 

                     

                    function menuInstaller() { 

                         try {

                                        app.menus.item("$ID/Main").submenus.item("File").remove();

                                    }catch(e){}

                                   

                                    menuT = "File",

                                     subT = "XXX";

                                     subs = app.menus.item("$ID/Main").submenus; 

                                    var refItem = app.menus.item("$ID/Main").submenus.item("$ID/&Layout");

                     

                     

                                    mnu = subs.item(menuT); 

                                        if( mnu == null ) { 

                                            mnu = subs.add(menuT, LocationOptions.after, refItem); 

                                        } 

                     

                     

                     

                     

                                    subsSubs = app.menus.item( '$ID/Main' ).submenus.item( menuT ).submenus;

                                        mnuSubMenu = subsSubs.item( subT ); 

                                        if( mnuSubMenu == null ) { 

                                            mnuSubMenu = subsSubs.add( subT); 

                                        }

                     

                     

                                                mnu.menuSeparators.add(LocationOptions.BEFORE,mnuSubMenu);

                                                };

                     

                     

                    alert("See your File manu XXX")

                     

                    //End coding

                     

                    Thanks

                    • 7. Re: [JS] Expand the top menu
                      [Jongware] Most Valuable Participant

                      Okay I now get what you are asking, so a new answer (apologies for muddying the issue – I understood it as "expanding the menu by adding new menu items"):

                       

                      No it is not possible.

                       

                      There is only very limited control over the User Interface through JavaScript. It is possible to show and hide some panels, but not the menu's. It's not possible to simulate mouse movement and mouse clicks.

                       

                      What you are asking is not the purpose of the JavaScript interface. Through JavaScript, you interact directly with an InDesign document, not through simulated operations which operate on the interface. There is no practical reason to 'open' the File menu and 'select' an operation when you can immediately call app.open(document), app.close(), and so on.