On the Mac (not sure about Windows), when I have a menu pulled down, I can press & release the option key and in many apps the menu changes dynamically, showing the options available with different modifier keys.
Is this available in Xojo or through MBS in some manner?
For an example. Pull down the Finder’s File menu and then press/release the option key
PS - bonus tip for reading this far: option click the speaker icon in the Mac’s menu bar to get useful additional options. Unfortunately, it’s not a live change like I’m looking for
Declare Sub setAlternate Lib "AppKit" Selector "setAlternate:" (NSMenuItem As Ptr, value As Boolean)
Dim p As Ptr = Ptr(UntitledItem0.Handle(MenuItem.HandleType.CocoaNSMenuItem))
setAlternate(p, True)
Both menu items need to have the same keyboard shortcut, the alternate one also needs the MacOptionKey set to ON in the IDE.
I can’t seem to get it to work, however. Even after following your instructions… also, it doesn’t seem to be documented on Apple’s site. Perhaps it’s deprecated in some way?
I see “Managing Alternates” where you can set “A Boolean value that marks the menu item as an alternate to the previous menu item” but i wasn’t planning on making menu items on the fly through Cocoa…
You do not need anything else than the above declare. Create two menu items in the Xojo menu editor.
Name: MyMenuItem1, Title: "ABC", KeyboardShortCut: "r", MacOptionKey: False
Name: MyMenuItem2, Title: "ABCDEF", KeyboardShortCut: "r", MacOptionKey: True
In the App’s Open event put the code from my previous post.
ok, well… I set them both up in the same menu, with the alternate after the original. I set up the modifier keys, etc identically except used MacOptionKey = On for the second. Then I ran the code once after launch. nothing. The alternate appears in the menu right after the original and it’s grayed out
I tried setting up the alternate menu item in a separate menu bar and grabbing it from there. Nope. Tried cloning it. nope…
not sure where to go from here. I’m not getting any errors…
hmmm… ok, I tried it in a test project and it works
My project was cloning a menu into an existing menu bar and I was attempting to do the Cocoa calls prior to it actually being placed into the bar… go figure.
Any chance it can be made to work without menu modifier keys? I see Apple does it in some menus ( Finder’s View->Clean Up ). I’d like to avoid adding modifier keys if the app doesn’t really need them for this function.
Either way thanks for the tip and your patience explaining
Also, assuming this type of thing isn’t available for Windows?
[quote=356995:@Steve Upton]On the Mac (not sure about Windows), when I have a menu pulled down, I can press & release the option key and in many apps the menu changes dynamically, showing the options available with different modifier keys.
Is this available in Xojo[/quote]
Yes you can do this in Xojo - no plugins required
It doesnt seem that you can set up alternates like the Finder View > Sort By / Arrange by pair (not sure why that is)
[quote=357064:@Norman Palardy]Yes you can do this in Xojo - no plugins required
It doesnt seem that you can set up alternates like the Finder View > Sort By / Arrange by pair (not sure why that is)
[/quote]
Are you referring to the declare that Eli mentioned or something else?