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.
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?
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/
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.
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.
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.
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.
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:&Window',600.0,'KBSCE Window menu'">FlexUIStroke</Menu>
Main:&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?
1 person found this helpful
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...
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:
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.
It is possible both in C++ and in scripting. I have never tried using the CS SDK...
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:
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
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
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:&Emerasoft',111.0,'KBSCE Application Menu'">My Panel Menu</Menu>
Unless you are defining the menu name as a ui string somewhere, make sure to add a dot after the separator:
My Panel Menu
Thanks Harbs! Another great suggestion ;-)
I just saw that my email did not show up correctly...
This is what it should look like:
<Menu Placement="'Main:.&Emerasoft',111.0,'KBSCE Application Menu'">My Panel Menu</Menu>