18 Replies Latest reply on Apr 6, 2011 8:04 AM by Harbs.

    Who's right?

    emerasoft.srl Level 1



      I was having a look to some documentation.


      In the official "Creative Suite Extension Builder" documentation, in the "Product-specific Guides > InDesign Guide" chapter, I found this:


      Custom menus in InDesign


      The menu items for extensions that you create with Adobe Creative Suite Extension Builder can only be shown in the menu Window > Extensions. If you want to start your extension from another menu, you can do so using an InDesign C++ plug-in. Your C++ menu plug-in must launch your Flash-based extension using the C++ PlugPlug API. To prevent your extension from being displayed in the Window > Extensions menu, remove the menu name from the extension manifest.

      For information on how to create a custom menu placement plug-in and how the plug-in can talk to your extension see the InDesign CS5 SDK (http://www.adobe.com/devnet/indesign/sdk/). .

      Once you have created both the C++ plug-in and Flash-based components of your extension, bundle them together for distribution as a hybrid extension. For details, see the Signing and Packaging Toolkit, which you can download from the Adobe Creative Suite SDK page, http://www.adobe.com/devnet/creativesuite/.


      But, inside the InDesign CS5 SDK, I found this on the "feature-development-with-scripting.pdf" (see page 23):


      Overriding default menu placement

      N O T E : Overriding the default menu position is supported by InDesign, but not yet by other Creative Suite applications.

      By default, CSXS supports a single main menu item, which appears in the application’s Window > Extensions menu. Extension developers may prefer a different menu location. InDesign sup- ports a Menu element and Placement attribute in the manifest.xml that allows an extension to override the default menu position. For example:

      <Menu Placement="'Main:&amp;Window',600.0,'KBSCE Window menu'">FlexUIStroke</Menu>

      The Placement attribute needs to be created with care. See the FlexuUIStroke code for a more precise example (without a line break).

      Strings must be enclosed in single quotes.

      Commas (without white space) are used to separate fields.


      Who's right?


      Thank you,


        • 1. Re: Who's right?
          Bob Stucky Adobe Employee

          Well, I have not tried either of those methods myself; but, they do work.


          If all you want to do is place the menu in a custom location, using the InDesign specific menu placement tag is the easiest, best, and recommended solution.


          In the latest SDK update we've included event support for InDesign, Photoshop, and Illustrator. That opens yet one more door for you.


          If your needs are significantly more complex, by that I mean -


          • You need fully custom menu structure (such as adding your own menu to the main, with a menu tree under that)
          • You need to turn menu items on or off based on application/document state
          • You need to create and manage context menus


          Here's how you would go about it:


                      mainMenu = InDesign.app.menus.item( "$ID/Main" ).submenus.add( "My Menu" );
                      var handler1Action: ScriptMenuAction = InDesign.app.scriptMenuActions.add( "The First Menu" );
                      IDScriptingEventAdapter.getInstance().addEventListenerToObject( "onInvoke", myEventHandler, handler1Action )

                      var handler1MenuItem: MenuItem = mainMenu.menuItems.add( handler1Action, LocationOptions.AT_END );




                  public function myEventHandler( evt: Event = null ): void
                      trace( "Menu Event fired" );




          To do context menus, I would suggest looking at Ole's extendscript examples and simply extrapolating that technique to ActionScript and using the IDScriptingEventAdapter for event support.






          • 2. Re: Who's right?
            emerasoft.srl Level 1

            Hello Bob,


            thank you very much for your reply. When talking about the "latest SDK update" do you mean the following?




            It seems to me this the latest we could download from the Adobe Devnet; or is the latest SDK included in the CS Extension Builder 1.0.1?




            • 3. Re: Who's right?
              Bob Stucky Adobe Employee

              Should be in both locations.


              If you've already installed Extension Builder, you can get this by selecting Help > Check for Updates and following the prompts.


              The update site for Extension Builder is: http://cssdk.host.adobe.com/cssdk/update/



              • 4. Re: Who's right?

                I'm writing an extension for InDesign using the Creative Suite SDK. I am an experienced Flex developer, but a newbie to developing extensions. I'm using Flash Builder 4 without the Extension Builder, on Windows XP.


                I have succeeded in building a simple extension which appears on the Windows/Extension menu and opens a document, as per the tutorials. But I would like my extension to launch from the right-click menu and have access to the object(s) that was/were selected when the user right-clicked.


                From this thread, I'm guessing I can do something like this in the manifest:


                <Menu Placement="RtMouseLayout ... something ... something ...


                Will that approach work? And where's the documentation to help me come up with the syntax for the attribute string?


                Thanks in advance.

                • 5. Re: Who's right?
                  Bob Stucky Adobe Employee

                  I do not believe that you can use the manifest entry to place a menu in the context menu.


                  You can create a context menu using InDesign's menu classes and the event adapter for InDesign.





                  • 6. Re: Who's right?
                    francispotter Level 1

                    Bob, thanks for the response.


                    I was able to get my menu item to show up on a context menu using this code:


                                        var app:com.adobe.indesign.Application = InDesign.app;
                                        var menus:Menus = app.menus;
                                        var menu:Menu = menus.itemByName("Layout Context Menu");
                                        var myAction:ScriptMenuAction = InDesign.app.scriptMenuActions.add("My Action");
                                        var newMenuItem:MenuItem = menu.menuItems.add(myAction, LocationOptions.AT_END);


                    ... but I'm not clear on how to actually get the invoke event to call an ActionScript method.


                    Earlier in this thread, you mention a class called IDScriptingEventAdapter. I don't seem to have a class called IDScriptingEventAdapter in Flex Builder; it doesn't appear to be in csaw_indesign, apedelta, or the CSXS library. I googled it, and only got one hit, which still doesn't tell me where to get it. I also searched in the InDesign CS5 Products SDK help (the CHM file that comes with the InDesign SDK) and it comes up blank too! Where do I find this all-important class?


                    Also, you mention examples by someone named Ole. Any links for those?


                    Thanks in advance.

                    • 7. Re: Who's right?
                      Bob Stucky Adobe Employee

                      The host adapter libraries are included with Extension Builder.



                      You need to add an event listener to the menu action.


                      IDScriptingEventAdapter.getInstance().addEventListenerToObject( "onInvoke", myHandler, myAction );


                      Ole's stuff is all over the forum, as well as included in the script samples for InDesign.





                      • 8. Re: Who's right?
                        emerasoft.srl Level 1

                        Hello Bob,


                        I am coming back on this after a long long time. My question is due to the fact I am not understanding the syntax of this solution:


                        <Menu Placement="'Main:&amp;Window',600.0,'KBSCE Window menu'">FlexUIStroke</Menu>


                        Main:&amp;Window = this is easy, it means "Window menu of Main menu bar"


                        600.0 = ?


                        KBSCE Window menu = I suppose this means again "Window menu of main menu" but why should it be written again?




                        • 9. Re: Who's right?
                          Harbs. Level 6

                          The number (600) is for the menu placement. See the SDK header file for menu placements.


                          KBSCE is for the section the keyboard shortcut appears under. Again, see the header file for a full list of sections...



                          1 person found this helpful
                          • 10. Re: Who's right?
                            emerasoft.srl Level 1

                            Thank you!!

                            • 11. Re: Who's right?
                              emerasoft.srl Level 1

                              It does not seem possible to me to add by the way a menu item on the InDesign main menu; assuming that I can find this on the "AdobeMenuPositions.h" header file:


                              • kWindowMenuPosition=110.0
                              • kScriptsMenuPosition=115.0
                              • kHelpMenuPosition=120.0


                              I tried something like this:


                              <Menu Placement="'Main',111.0,'KBSCE Main menu'">MyTestMenu</Menu>


                              without any luck (I also tried some others without any luck). So I am presuming it is not possible.



                              • 12. Re: Who's right?
                                Harbs. Level 6

                                It is possible both in C++ and in scripting. I have never tried using the CS SDK...



                                • 13. Re: Who's right?
                                  emerasoft.srl Level 1

                                  Ciao Harbs,


                                  I think I finally came to a solution for my panel "lifecycle"; my need was the following:


                                  - to be able to create a Submenu (and submenus of this one) of the InDesign Main Menu ("$ID/Menu") when InDesign starts WITHOUT having to show my panel or having it automatically started


                                  So I finally found this solution:


                                  • called my "menu tree" creation procedure inside a function called by the creationComplete event of my panel
                                  • set some "manifest.xml" Lifecycle attributes to have:
                                    • "AutoVisible"=false
                                    • "StartOn>Event"=applicationActivate


                                  This way my menu-tree is created whenver InDesign is launched and the panel is not automatically shown


                                  I don't know if there is any other solution better than this, but it is working




                                  • 14. Re: Who's right?
                                    emerasoft.srl Level 1

                                    But I discovered another strange behaviour:


                                    • if my panel is a mx:Application, then it works as described in my previous post
                                    • when changed it into a csxs:CSXSWindowedApplication then the panel is automatically always shown when the application (InDesign) is started even if the AutoVisible attribute of Manifest.xml is set to false



                                    • 15. Re: Who's right?
                                      emerasoft.srl Level 1

                                      Coming back to my very previous attempts (modifying the manifest.xml file with "placement" attribute on the "Menu" item, I found this way working:


                                      <Menu Placement="'Main:&amp;Emerasoft',111.0,'KBSCE Application Menu'">My Panel Menu</Menu>



                                      • 16. Re: Who's right?
                                        Harbs. Level 6

                                        Unless you are defining the menu name as a ui string somewhere, make sure to add a dot after the separator:


                                        My Panel Menu




                                        • 17. Re: Who's right?
                                          emerasoft.srl Level 1

                                          Thanks Harbs! Another great suggestion ;-)

                                          • 18. Re: Who's right?
                                            Harbs. Level 6

                                            I just saw that my email did not show up correctly...


                                            This is what it should look like:


                                            <Menu Placement="'Main:.&amp;Emerasoft',111.0,'KBSCE Application Menu'">My Panel Menu</Menu>