Skip to main content
Known Participant
May 18, 2017
Question

Framemaker 2017 ESTK Add Custom Menu

  • May 18, 2017
  • 2 replies
  • 579 views

Hello,

Can anyone share the new function names for adding a new menu ... and if possible, the name of the View menu.

Thanks,

Tracey

This topic has been closed for replies.

2 replies

frameexpert
Community Expert
Community Expert
May 18, 2017

var viewMenu, cmd;

viewMenu = app.GetNamedMenu ("ViewMenu");

cmd = viewMenu.DefineAndAddCommand (10, "ViewNavigatorPaletteCmd", "View Navigator Palette", "");

This is a simple way to add a single command to the View Menu. Then you need to handle the command when it is invoked. You use the built-in Command function:

function Command (cmd) {

    switch (cmd) {

        case 10 :

            openNavigatorPalette ();

            break;

    }

}

If you only have a single command, you don't need a switch statement, but typically you are handling multiple commands.

-Rick

www.frameexpert.com
Legend
May 18, 2017

Hi Tracey,

I have a sample here that shows how to add a menu:

FrameMaker ExtendScript Samples - West Street Consulting

Look for script 05.01. For the name of the view menu, I think it is ViewMenu. Below is a function that I use when I need to find a menu or command name. It allows you to enter an optional filter string to narrow the results. If the specified string is a case-insensitive substring of the command label, it is reported, otherwise it is skipped. Since the label of the View menu is "View", I just entered "view". and ran the script to find ViewMenu.

Hope this helps.

Russ

function reportMenusAndCommands()

{

    var filter = prompt ("Filter for the menu/command search?", "(none)", "Menu/command search");

    if(filter == null) return;

    if(filter == "(none)") filter = "";

    var cmd = app.FirstMenuItemInSession;

   

    while (ov(cmd))

    {

        var cmdLabel =  cmd.Label.replace("&", "").toLowerCase();

        if(filter == "" || cmdLabel.toLowerCase().indexOf(filter) > -1)

        {

            if(!confirm("Command label:      " + cmd.Label

                + "\nCommand name:     " + cmd.Name

                + "\n\nClick No to abort the search.")) return;

           

        }

   

        cmd = cmd.NextMenuItemInSession;

    }

}