I am working on a project using Objective C on macOS. The project is Document-Base Application. Each window contains a WebView. I want to implement copy: cut: and paste: where the menu items for these actions should be enabled/disabled according to the object selected inside the WebView. I started a new Document-Base Application and added the following code inside AppDelegate.m:
- (void)copy:(id)sender {
NSLog(@"%@ %s", self, __func__);
}
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
NSString *title = [menuItem title];
NSLog(@"%@",title);
return YES;
}
Before I add the WebView to the Document.xib file, everything is working fine and both copy and validateMenuItem functions are called normally. When I add WebView to the Document.xib file, these function stop working. I tried many things (such as override the WebView class) without any success. I know WebView is deprecated, but using WKWebView will cause other issues.