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

Where to place menu for both book and doc?

Community Expert ,
Jul 05, 2013 Jul 05, 2013

Copy link to clipboard

Copied

Dear all,

The script I'm developing creates a menu for the various steps to be taken by the user. It acts both on a single document or on a book (all of it's documents). Adding the custom menu to the SpecialMenu works fine for the documents. This standard menu is not available if a book is active. Hence I tried to connect it to the FormatMenu.

function DefineMenus() { 
     var menuMain = {en: "Bibliography with EndNote …",
                    de: "Bibliografie mit EndNote …"};
     var menuDocu = {en: "Documentation",
                    de: "Beschreibung (en)"};
     var menuLocation = app.GetNamedMenu("FormatMenu");
     var bibenMenu  = menuLocation.DefineAndAddMenu("!BIBENmain", (localize(menuMain)));
     bibenMenu.DefineAndAddCommand(1,"BibenDocu",    (localize(menuDocu)), "");
}

I observe the following:

  1. Invoke the script after FM has started and no book or document is open:
    The menu is placed and available in an open document, but not in a book independently which is opened first.
  2. Invoke the script after opening a document and then a book:
    The menu is available in the document, but not in a book
  3. Invoke the script after opening a book and then a document:
    The menu is available in the document, but not in a book

What must be done that the menu is available for books and documents?

TOPICS
Scripting

Views

724

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

correct answers 1 Correct answer

Community Expert , Jul 05, 2013 Jul 05, 2013

Thanks Jang - in the meantime I had a similar idea, noting that in the menu.cfg files there both a FormatMenu and a BookFormatMenu exists. But even this does not help:

     var menuLocation = app.GetNamedMenu("FormatMenu");
     var bibenMenu  = menuLocation.DefineAndAddMenu("!BIBENmain", (localize(menuMain)));
     bibenMenu.DefineAndAddCommand(1,"BibenDocu",    (localize(menuDocu)), "");
     menuLocation = app.GetNamedMenu("BookFormatMenu");
     var bkbibenMenu  = menuLocation.DefineAndAddMen
...

Votes

Translate

Translate
Advocate ,
Jul 05, 2013 Jul 05, 2013

Copy link to clipboard

Copied

Hello Klaus,

AFAIK, you need to define two menus, or submenus. They can have the same commands added to them, but must be two separate items, which you can then add to the respective menus. All menus in FM are linked together in a linked list, which is why the same menu cannot appear in two locations, even if these are never both visible.

I hope this helps. I have been struggling with this and creating two separate menus solved my problems.

Ciao

Jang

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 05, 2013 Jul 05, 2013

Copy link to clipboard

Copied

LATEST

Thanks Jang - in the meantime I had a similar idea, noting that in the menu.cfg files there both a FormatMenu and a BookFormatMenu exists. But even this does not help:

     var menuLocation = app.GetNamedMenu("FormatMenu");
     var bibenMenu  = menuLocation.DefineAndAddMenu("!BIBENmain", (localize(menuMain)));
     bibenMenu.DefineAndAddCommand(1,"BibenDocu",    (localize(menuDocu)), "");
     menuLocation = app.GetNamedMenu("BookFormatMenu");
     var bkbibenMenu  = menuLocation.DefineAndAddMenu("!BIBENmain", (localize(menuMain)));
     bkbibenMenu.DefineAndAddCommand(1,"BibenDocu",    (localize(menuDocu)), "");

The effect is the same as before!

I'm invoking the script without using the ESTK (because this does not work for my custom-installation of FM). I write the script in EditPadPro, save it and invoke it via File > Scripts > Run (or the catalogue). So far I'm successful - atbeit somewhat slow - with my development.

This separtation process may require that I do the second part of the menu definition this way:

     menuLocation = app.GetNamedMenu("BookFormatMenu");
     var bkbibenMenu  = menuLocation.DefineAndAddMenu("!bkBIBENmain", (localize(menuMain)));
     bkbibenMenu.DefineAndAddCommand(1,"BibenDocu",    (localize(menuDocu)), "");

In this case the menu entry Format > Bibliography... is present in both the document and the book, but in the book it is gray (inactive). So there is still a missing link.

Ah, now I got it: also the submenu items must be different:

     var menuLocation = app.GetNamedMenu("FormatMenu");
     var bibenMenu  = menuLocation.DefineAndAddMenu("!BIBENmain", (localize(menuMain)));
     bibenMenu.DefineAndAddCommand(1,"BibenDocu",    (localize(menuDocu)), "");
     menuLocation = app.GetNamedMenu("BookFormatMenu");
     var bkbibenMenu  = menuLocation.DefineAndAddMenu("!bkBIBENmain", (localize(menuMain)));
     bkbibenMenu.DefineAndAddCommand(1,"bkBibenDocu",    (localize(menuDocu)), "");

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