• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Moving menu commands

Community Expert ,
Jan 22, 2016 Jan 22, 2016

Copy link to clipboard

Copied

Has anyone had success adding custom commands to FrameMaker menus and then moving them to different locations on the menu? I can do this with the FDK and FrameScript but I haven't had success with ExtendScript. I am defining a custom command and adding it to the File menu. I want to move it up under the Save As XML command. Here is what I am using:

#target framemaker

var menu, cmd, saveCmd;

// Get the File menu.

menu = app.GetNamedMenu ("FileMenu");

// Create the command and add it to the File menu.

cmd = menu.DefineAndAddCommand (10, "SaveAsPdfQuickCmd", "Save As PDF Quick","");

cmd.EnabledWhen = Constants.FV_ENABLE_NEEDS_DOCP_ONLY;

// Move the command up in the menu.

saveCmd = app.GetNamedCommand ("SaveAsXml");

cmd.PrevMenuItemInMenu = saveCmd;

// must call if script has been run through ESTK, redundant otherwise.

UpdateMenus ();

The custom command gets added to the File menu, but it stays at the bottom of the menu. Any help would be appreciated. Thanks.

-Rick

TOPICS
Scripting

Views

2.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 22, 2016 Jan 22, 2016

Copy link to clipboard

Copied

Hi Rick,

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 22, 2016 Jan 22, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 22, 2016 Jan 22, 2016

Copy link to clipboard

Copied

Hi Rick,

I will test it next week.

I'll come back with my results the next days.

Have a nice weekend

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jan 25, 2016 Jan 25, 2016

Copy link to clipboard

Copied

Hi Rick,

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.

Russ

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2016 Jan 25, 2016

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jan 25, 2016 Jan 25, 2016

Copy link to clipboard

Copied

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.

Russ

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 26, 2016 Jan 26, 2016

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 22, 2018 Sep 22, 2018

Copy link to clipboard

Copied

Hi I've just started to learn about adding custom commands to a menu, is there a solution to this problem yet ? I'm using Framemaker 2019 and still can't change the order of the commands

Regards

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 01, 2019 Jul 01, 2019

Copy link to clipboard

Copied

This problem still exists in FrameMaker 2019. I doubt that Adobe will pay it much attention, given it was first reported in 2012, however I have created a new bug (I couldn't find Klaus's bug in the new Adobe bug site) Tracker . My be worth voting for if the problem still affects you.

To get the menu command item in the right place for the project I am working on, I will have to use a C++ plugin to create the menu item, and then call the ExtendScript file on activation, which, while it works, is a real pain, when having PrevMenuItemInMenu or NextMenuItemInMenu working properly is easy.

Jon

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 02, 2019 Jul 02, 2019

Copy link to clipboard

Copied

Just recently I placed this in the beta test forum:

«It is still not possible to place a menu item relative to existing one, as it is possible with the Order statemetn in menus.cfg.

There is ample discussion about the problem - see for example https://forums.adobe.com/thread/2072245 or bug FRMAKER-2752. »

Put emphasis on this subject by voting on Jon's Bug report.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 02, 2019 Jul 02, 2019

Copy link to clipboard

Copied

Thanks Klaus.  I am maybe not so surprised Adobe have not fixed this problem. My bet is that not so many script writers are adding menu items in ExtendScript. That said it would seem to be something that is easy to fix?

Jon

p.s. I did search through bug tracker looking for your bug report. The search tool is a bit limited and I did not search for menu in the title but in the description. In any case Adobe can close one or the other as duplicates.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 02, 2019 Jul 02, 2019

Copy link to clipboard

Copied

They might have already done so? FRMAKER-2752  is closed as a Duplicate?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

Well, I'll add my voice here, because I make menu items regularly with both the FDK and ExtendScript. I am equally dismayed by this problem, because what am I going to do... launch scripts from the ExtendScript toolkit every time? Of course not. A menu item is a basic UI tool, so it is odd that this has been neglected, especially given the enormous effort it must have taken to implement ExtendScript in the first place. It is generally a marvelous and powerful thing... but this bug is like building a fabulous car but then sticking door handles on the passenger side only. Anyway, that is my rant, thanks for the space!

Russ

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 03, 2019 Jul 03, 2019

Copy link to clipboard

Copied

LATEST

Thanks Russ. I see the vote count has gone up, thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines