Trouble with menus converting API1 to API2

I created a base class and converted all my Windows to DesktopWindows. But when I try to run the app in the debugger, I get errors concerning the menu conversion. I saved the app as a xojo_project and found two lines in the source that I have tried modifying without success. When I try to run the app, the error message is

Type mismatch error. Expected class DesktopMenuBar, but got class DesktopMainMenuBar.DesktopMainMenuBar

245184511

The two lines in SoCal2.xojo_project with MenuBar in them are:

MenuBar=DesktopMainMenuBar;DesktopMainMenuBar.xojo_menu;&h000000000E9D37FF;&h0000000000000000;false

AppMenuBar=DesktopMainMenuBar

The file DesktopMainMenuBar.xojo_menu begins with (I left out all the menu details)

#tag Menu
Begin Menu DesktopMainMenuBar
Begin MenuItem FileMenu
SpecialMenu = 0

I am hoping for a simple fix for this but have tried about 100 different ways to modify the text files without success.

Load the project in the IDE and right click on the MenuBar and choose Convert to api2 from the context menu.

Desktop windows can only use DesktopMenus and old Windows can only use MenuBars.

Always use the ide to perform the conversions. Don’t try and do it by hand. Methods, events etc differ between APIs. Convert will make these changes for you.

4 Likes

Did you use the ā€˜Convert to DesktopMenuItem’ for the contextual menu for MainMenuBar?
The conversion does not change the name of the menu, but change the MenuItems to DesktopMenuItems.
If AppMenuBar uses MainMenuBar, then you may need to convert the App section to DesktopApplication

Edit: MainMenuBar before conversion

#tag Menu
Begin Menu MainMenuBar
   Begin MenuItem FileMenu

MainMenuBar after conversion

#tag Menu
Begin Menu MainMenuBar
   Begin DesktopMenuItem FileMenu

Revert to the original menu and convert that in one go.

DesktopMenuBar’s can only contain DesktopMenuItems, The whole thing need to be converted in one go. Do the conversion in the IDE sidebar of the MenuBar, not in the Window. I wouldn’t even try and convert the system outside of the IDE.

AlbertoD’s example is correct.