@Kimpoy, thanks for the reference to performKeyEquivalent!
For completeness, I implemented it this way...
Subclass your webview from WebView and implement the method:
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent {
NSString * chars = [theEvent characters];
BOOL status = NO;
if ([theEvent modifierFlags] & NSCommandKeyMask){
if ([chars isEqualTo:@"a"]){
[self selectAll:nil];
status = YES;
}
if ([chars isEqualTo:@"c"]){
[self copy:nil];
status = YES;
}
if ([chars isEqualTo:@"v"]){
[self paste:nil];
status = YES;
}
if ([chars isEqualTo:@"x"]){
[self cut:nil];
status = YES;
}
}
if (status)
return YES;
return [super performKeyEquivalent:theEvent];
}
Credit to @aventurella over here: https://github.com/Beats-Music/mac-miniplayer/issues/3. Just modified slightly to return the super response as default because it should propagate down to its subviews.
As a note, I'd recommend implementing a log or similar in your custom webview to make sure you really are working with your class:
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
// Drawing code here.
NSLog(@"Custom webview running...");
}