Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Ensure selector sent only when CEF isn't wired up to handle it
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhsasikumar committed Nov 10, 2014
1 parent b1fbfdc commit d8bd8f9
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions appshell/cefclient_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,12 @@ - (void)setHandlingSendEvent:(BOOL)handlingSendEvent {

- (void)sendEvent:(NSEvent*)event {
if ([event type] == NSKeyDown) {
// We've removed cut, copy, paste from the edit menu,
// so we handle those shortcuts explicitly.
if ([event modifierFlags] & NSCommandKeyMask) {
// If mainWindow is the first responder then cef isn't the target
// so let the application event chain handle it intrinsically
if ([[self mainWindow] firstResponder] == [self mainWindow] &&
[event modifierFlags] & NSCommandKeyMask) {
// We've removed cut, copy, paste from the edit menu,
// so we handle those shortcuts explicitly.
SEL theSelector = nil;
NSString *keyStr = [event charactersIgnoringModifiers];
unichar keyChar = [keyStr characterAtIndex:0];
Expand All @@ -91,11 +94,7 @@ - (void)sendEvent:(NSEvent*)event {
} else if (keyChar == 'x'){
theSelector = NSSelectorFromString(@"cut:");
} else if (keyChar == 'a'){
// If mainWindow is the first responder then cef isn't the target
// so let the application event chain handle it intrinsically
if ([[self mainWindow] firstResponder] == [self mainWindow]) {
theSelector = NSSelectorFromString(@"selectAll:");
}
theSelector = NSSelectorFromString(@"selectAll:");
}
if (theSelector != nil) {
[[NSApplication sharedApplication] sendAction:theSelector to:nil from:nil];
Expand Down

0 comments on commit d8bd8f9

Please sign in to comment.