Skip to main content
DrDaveJ
Inspiring
August 25, 2015
Answered

RemoveMenu, not working

  • August 25, 2015
  • 2 replies
  • 1276 views

Whether I AutoRun at startup, or wait and run manually when needed,

I add a menu to the main menu bar with this:

//Create menu

var myMenu = DefineMenu("Daves_ScriptingMenu", "Dave's Scripts");

//Get the main FM document menu, so we can

//add our custom menu, then add it.

var fmMenu = app.GetNamedMenu ("!MakerMainMenu");

fmMenu.AddMenuToMenu (myMenu);

. . . I add commands, etc. that are working.

The problem is removing the menu when I don't want it there.

I'm trying this code. It appears to run, but nothing happens. And there are no

messages generated in the Console.

Notice I tried using the menu name as well as its label.

//Get the main FM document menu, and then remove custom menu.

var fmMenu = app.GetNamedMenu ("!MakerMainMenu");

//Using Label

RemoveMenu(fmMenu, "Dave's Scripts");

//Using Name

//RemoveMenu(fmMenu, "Daves_ScriptingMenu");

UpdateMenus();

Can I get a hint as to what's up here?

Thanks,

Dave

This topic has been closed for replies.
Correct answer Russ Ward

Alas, none of that worked.

You gave me ideas about mixing and matching .properties, menu names/labels, etc.  No joy.

Now, I am off this project and onto something else for a couple days. Will tackle this again while I am on vacation, starting Thurs/3rd.

My next guess is to remove Commands from the Menu, and then see if the Menu will Remove.

Thanks for the feedback!

Dave


It works fine here. The only other thing I could suggest is the obvious... make sure you have the right name of your menu. You could test with alert(fmDavesMenu.Label).

Russ

2 replies

DrDaveJ
DrDaveJAuthor
Inspiring
August 26, 2015

Running FM v12.0.4.445 on Win 7 pc.

When I run the script using Run Button in script catalog, it would register my click, but nothing happened.

Now, thinking maybe there are issues with the Script Library/Catalog, I run the script from within the Editor.

This generates an error I had not noticed previously:

"app.GetNamedMenu is not a function"

However, according to the scripting guide (last updated 4/8/2014), I have this syntax correct. The line is shown in my initial post.

Help please?

Thanks,

Dave

Legend
August 26, 2015

Dave,

Some time ago, I had a similar frustration with deleting commands (that is, it didn't work). See the following post... there is a link to an FM12 patch release notes that might be informative. But I'm not sure because I never got the patch   You don't mention your version of FM, so I don't know if this will be helpful or not.

Command object Delete() and CommandNum property issues

Russ

Klaus Göbel
Legend
August 27, 2015

Hi Russ,

here's the solution : Re: Command object Delete() and CommandNum property issues

(I hope )

Russ WardCorrect answer
Legend
August 31, 2015

Alas, none of that worked.

You gave me ideas about mixing and matching .properties, menu names/labels, etc.  No joy.

Now, I am off this project and onto something else for a couple days. Will tackle this again while I am on vacation, starting Thurs/3rd.

My next guess is to remove Commands from the Menu, and then see if the Menu will Remove.

Thanks for the feedback!

Dave


It works fine here. The only other thing I could suggest is the obvious... make sure you have the right name of your menu. You could test with alert(fmDavesMenu.Label).

Russ