How can I detect that option key is pressed when a menu is selected, to:
- change menu title
- perform a specific action
Apple doc on this is really below minimum (useless):
Managing Alternates
var isAlternate: Bool
A Boolean value that marks the menu item as an alternate to the previous menu item.
More generally, I would like to set a global value each time the altrenate key is pressed in my app.
How can I detect that option key is pressed when a menu is selected, to:
That’s not how you generally do things. Rather, you create multiple menu items next to each other in the menu bar, with all but the first having the
isAlternate
set. The system then merges them together and only shows the one that matches the current modifiers. And because they are separate menu items, they can have separate actions.
To see this in action:
Create a new project from the Cocoa Application template
In the main menu, select Paste and Match Style and check Alternate in the Attributes inspector
Run the app
When you bring down the edit menu, you’ll just see Paste
If you press command-shift, it’ll change to Paste and Match Style
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"