Question:
How can I make it so that the 'undo' menuItem actions reaches the NSApplication-subclass?
Context:
In my storyboard there is an NSMenuItem called 'Undo', it came with the template.
My app uses a subclass of NSApplication, and in this class I implemented
@objc func undo(_ sender: Any){}
I did not implement
override func validateMenuItem(_ menuItem: NSMenuItem) -> Bool
In the storyboard the menuItem's action is 'undo:', and the target is 'first responder'.
The problem I have is that the menuItem is never enabled, and when I implement 'validateMenuItem(_:)', it is called only for 'startDictation:' and 'orderFrontCharacterPalette:'.
However, when I change the method signature in my NSApplication subclass to:
@objc@IBActionfunc undo2(_ sender: Any)
and update the storyboard to use this action, this method DOES get called (note that it is called undo2)
My application is not document based, and the structure is:
WindowController -> Window -> ViewController -> TableView
Not sure it if this is relevant, but the viewController implements cut, copy, paste and delete, and as such has a validateMenuItem(_:) implementation.