How to remove and add back menus from the MenuBar

I’ve tried to locate the process for managing the main menubar.
This question is because Windows doesn’t allow the hiding of MenuItems.
I also have learned the hard way that a second menubar doesn’t work.

For purposes of this question, assume I want to focus on the Edit Menu.
What I want to do is remove on Window.Open everything from the EditMenu, and on close of the Window, I want to add everything back.

The remove I can figure out. The problem is adding everything back.
What are the tricks or processes?
How do I get EnableMenuItems to fire on the close of the window, or what do I do instead?

Is it possible to remove a Menu from a MenuBar ?

No, I do not ask i it is possible to remove a MenuItem from a Menu.

MenuItem.Remove is deprecated… and MenuBar’s Remove links to… MenuItem.Remove.

The Docs example for MenuItem.RemoveAt is about that - Removing the EditMenu. So yes.

MenuItem.RemoveMenuAt

EditMenu.RemoveMenuAt(3) ???

It does for me…
You can have different menus for different windows, assigned in the IDE.
When your window has the focus, it shows the menu associated with it.

But if you determined to hide edit menu items when a window opens, and put them back afterwards,
Try setting the text to be “-” in the enablemenuitems event, and setting them back in the window close or Application enablemenuitems event

My problem with the second MenuBar is I would assign it to certain windows but when that window is closed, the MenuBar still remains. Maybe I should be doing this assignment by code?

This is the code example from Window.MenuBar.

[code]If Self.MenuBar <> Nil Then
#If TargetMacOS Then
App.MenuBar = Nil
#Endif
Self.MenuBar = Nil
Else
#If TargetMacOS Then
App.MenuBar = MainMenuBar
#Endif

Self.MenuBar = MainMenuBar
End If[/code]

Do I have to call both App and Self.MenuBar = MainMenuBar ?
Is that how you get the second MenuBar to work?