you can find the answer in FDK Programmer's Guide
Section "Reordering menus and menu items" page 393
To change a menu or menu item’s position on a menu, set its
FP_NextMenuItemInMenu or FP_PrevMenuItemInMenu properties to specify
the IDs of other menus or menu items on the menu. You need to set only one of these
properties. FrameMaker automatically sets the other one for you.
I hope that helps.
Hi Klaus, Thanks for your answer, but my ExtendScript code doesn't work. I am not sure if it is a bug in ExtendScript or if it has to be done differently than in the FDK. -Rick
I will test it next week.
I'll come back with my results the next days.
Have a nice weekend
I observe the same behavior. I've also observed in the past that menu.Delete() doesn't work either. I can't remember whether they fixed that or not.
Hi Russ, Yes, there is some kind of disconnect between the command and the menus it resides on. When you do this in the FDK with F_ApiSetId, one of the parameters is the menu id (see lines 10 and 12). The menu id is critical because a particular command can appear on any number of menus.
// Add the custom straddle columns command to the table menu. straddleColsCmd = F_ApiDefineCommand(STRADDLE_COLS, "StraddleCols", "Straddle Columns Only (Preserve Rows)", ""); F_ApiAddCommandToMenu(tableMenuId, straddleColsCmd); F_ApiAddCommandToMenu(tableContextMenuId, straddleColsCmd); F_ApiSetInt(FV_SessionId, straddleColsCmd, FP_EnabledWhen, FV_ENABLE_IS_CELLS); // Move the command so that it comes after the straddle command. F_ApiSetId(tableMenuId, straddleColsCmd, FP_PrevMenuItemInMenu, straddleCmd); F_ApiSetId(tableContextMenuId, straddleColsCmd, FP_PrevMenuItemInMenu, straddleCmd);
FrameScript is similar. For example,
// Get the table menu. Get Object Name('TableMenu') Type(Menu) NewVar(oTblMenu); // Make the new command. New Command Name('StraddleCols') Label('Straddle Columns Only (Preserve Rows)') NewVar(oStraddleColsCmd) EventProc(StraddleColsEvent); // Add the command to the table menu. Add CommandObject(oStraddleColsCmd) To(oTblMenu); // Move the custom command so it appears after the built-in Straddle command. Get Object Name('TableStraddle') Type(Command) NewVar(oStraddleCmd); // *** First assign the parent menu object to the command. Set oStraddleCmd.Menu = oTblMenu; // Now it can be moved. Set oStraddleColsCmd.PrevMenuItemInMenu = oStraddleCmd;
Line 11 is the key because it tells you which menu item you are referring to for the existing command. I can't figure out how to specify the parent menu of a command with ExtendScript. -Rick
Rick, I get it now. You are right... the parent menu is a fundamental parameter when defining or retrieving NextMenuItemInMenu, etc., but there seems to be no way to specify it. Using the debugger, I see that the NextMenuItemInMenu and PrevMenuItemInMenu properties always return an invalid object, no matter which way you come at them.
Since the debugger suggests that the documentation is correct (or at least intends to be), I think this must be an incomplete implementation. With regrets, I don't have any other ideas. This seems very unfortunate indeed. Perhaps Adobe would regard this as an issue worthy of attention.