Thanks.
I already tried but that doesn’t work.
Another error shows up saying ; Parameter “index” expects type integer, but this is class DesktopMenuItem.
‘mnu1’ is a menu in the menubar mnuFrmMixMaster
In XOJO 2021r1.1 There are 2 possibilities ;
MenuItem.Remove(Index As Integer) → Removes the MenuItem specified by its index. MenuItem.Remove(Item As MenuItem) → removes the menu specified by reference.
For the code in bold I am looking for a replacement in XOJO 2022r1.
@MarkusR
That is just my problem : after changing to DesktopMenuItem Remove by reference is no more available ???.
I’m looking for a way to solve this…
You Can’t mix DesktopMenus and MenuItems or vice versa. You can only add DesktopMenuItems to a DesktopMenu. You can only add MenuItems to a Menu. All the classes either have to be Desktop or Not.
Just loop through the children of the parent menu to find the index and then use it with RemoveMenuAt. That’s what would have been done under the hood anyway.
You can also possibly find the menu item, using ParentMenu.Child and call its “close” method. I haven’t tried in this context, but you can give it a try.
I found a solution ;
As it are 2 menus that are dynamically created when running, they are placed at the end of the menubar (two last indexes).
So I do twice a 'menuBar.RemoveMenuAt(menuBar.LastRowIndex)
This does exactly what i wanted.
However I will later on search for a better solution.
Or perhaps XOJO will create a Remove menu by reference as existed before API2.