Kris Coppieters
|
It is possible to add menu items that appear outside of the 'standard' API menu.
In order to do so, you need to know the 'absolute menu path' that leads to the location of the new menu item.
Menu paths are a bit like file paths - they show how menu items are nested, and you can use either relative or absolute paths.
Path components are separated by colons, and the registerMenuItem method interprets menu items without any colons as being relative to the API menu. If the menu item has any colons, it will be interpreted as an absolute path.
The following paths are of particular interest:
Main:0x90B50kActivePageItemMenuKey: Main:&Edit:Preferences:
The first path is the absolute path to the API menu item itself. The second is the absolute path to the InDesign preferences menu.
Prefixing your menu items with these path expressions allows you to use submenus and create preferences menus. A few examples (taken from our freebie plug-ins): [tt] gChatterGoofyPlugin.registerMenuItem( "menuChatterGoofyPrefs", "Main:&Edit:Preferences:ChatterGoofy Prefs..."); [/tt]
This adds a new menu item to the InDesign preferences menu.
[tt] thePlugin.registerMenuItem( "menuStoryLeftPark", "Main:0x90B50kActivePageItemMenuKey:StoryParker:Park Story Left"); thePlugin.registerMenuItem( "menuStoryRightPark", "Main:0x90B50kActivePageItemMenuKey:StoryParker:Park Story Right"); thePlugin.registerMenuItem( "menuStoryRePark", "Main:0x90B50kActivePageItemMenuKey:StoryParker:Repark Story"); thePlugin.registerMenuItem( "menuStoryUnPark", "Main:0x90B50kActivePageItemMenuKey:StoryParker:Unpark Story"); thePlugin.registerMenuItem( "menu-StoryParker-1", "Main:0x90B50kActivePageItemMenuKey:StoryParker:-"); thePlugin.registerMenuItem( "menuLeftPark", "Main:0x90B50kActivePageItemMenuKey:StoryParker:Park Left"); thePlugin.registerMenuItem( "menuRightPark", "Main:0x90B50kActivePageItemMenuKey:StoryParker:Park Right"); thePlugin.registerMenuItem( "menuRePark", "Main:0x90B50kActivePageItemMenuKey:StoryParker:Repark"); thePlugin.registerMenuItem( "menuUnpark", "Main:0x90B50kActivePageItemMenuKey:StoryParker:Unpark"); thePlugin.registerMenuItem( "menu-StoryParker-2", "Main:0x90B50kActivePageItemMenuKey:StoryParker:-"); thePlugin.registerMenuItem( "menuAllUnpark", "Main:0x90B50kActivePageItemMenuKey:StoryParker:Unpark all"); [/tt]
This builds up the Story Parker menu as a submenu of the API menu. Note the use of '-' as a menu item to get menu separators, and the fact that the 'StoryParker' menu itself does not need to be created - simply creating one of its submenus causes it to be created as well.
|