Desktop
Are there strategies for first removing a MenuIttem knowing that it will be returned.
For instance, on Windows, I have a small window and if I remove one, then it fits.
So, I need to remove a menu, with the idea of returning it.
Does Clone work in this case? Is there an effective way of stashing it?
Is there a better technique.
You’ll have to add it back as a new menuitem:
https://documentation.xojo.com/api/user_interface/desktop/desktopmenuitem.html
The following code adds a Select All menu item to the Edit menu.
Var EditPasteSpecial As New DesktopMenuItem
EditPasteSpecial.Text = "Paste Special..."
EditMenu.AddMenuAt(5, EditPasteSpecial)
See also AddMenuAt: https://documentation.xojo.com/api/user_interface/desktop/desktopmenuitem.html.AddMenuAt
You can also hide or show menutems and disable / enable them - this might be easier than removing and adding them back.
Thanks for the response, but I’m wondering if there’s a more uhm elegant solution, something to do with arrays.
I also have to disagree on “visible”
From https://documentation.xojo.com/api/user_interface/desktop/desktopmenuitem.html.Visible
This property does nothing on Windows so use DesktopMenuItem.RemoveMenuAt instead.
There’s nothing to disagree on, it’s a fact. Setting a MenuItem.Visible=false on Windows doesn’t do anything.
Thanks. Next time I won’t be kind.
In general I try to avoid removing MenuItems and rather enable/disable them. It helps users discover features by leaving the item in the menu but disabled unless contextually appropriate.
I had the same thoughts.
I got tired of seeing in my Recent Items menu “Untitled” and wondered if there was something I could do about it.
If nobody else replies, I’ll be happy.
I am still curious how clone works. I saw it used in the example “ConstructContextualMenu” for Help
base.AddMenu(HelpMenu.Clone)