The declare wouldn’t compile as-is (that thread is old), but this does
Declare Sub setAlternate Lib "AppKit" Selector "setAlternate:" (NSMenuItem As Ptr, value As Boolean)
Dim p As Ptr = myMenu2.Handle()
I’ve created two identical menus right next to each other, and placed the declare in the App.opening event, which was the advice in that thread. When I run the app, both menus appear in the menubar. Since I’m not clear on what the declare does (for example, how does myMenu2 know it’s the alternate to myMenu1?), I’d appreciated thoughts on what I’m not doing correctly. Also, when polling for the OptionKey.down event in a timer, how does one actually invoke the alternate menu when it is pressed
I did not say it failed to operate. I did not say the declare was going to work on Windows, or that it would be a great cross platform solution. All I said was there is a correct, Apple provided way to do this on macOS (the subcategory where this thread is located).
This should not be a goal when trying to achieve something the Xojo Framework does not directly allow.
The alternate item declare works great when you follow Eli Ott’s instructions and know how to update declares for API 2.0. There’s also no lag to the functionality, as I suspect you will find with a Timer.
I saw that error during conversion because DesktopMenuItem.Handle and MenuItem.Handle accept different parameters. I might suggest double checking you were working with MenuItem and not a DesktopMenuItem.
I created a new project specifically for testing the menu code using Xojo2023r1.1, so it is a DesktopMenuItem. I figured it might be an API1 vs API2 thing, I’m not that conversant in API2. My real app will use the API1 code. Thanks.
If you’re going to be working in API 1 for a while, I might suggest that you create an API 1 project template so that you can test things with API 1 controls. Using an older IDE, save a project named Default Desktop Project.xojo_binary_project in a folder named Project Templates next to Xojo.app/exe.