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

Commit 6cbe86f

Browse files
committed
Merge pull request #481 from anirudhsasikumar/fixselectall
Support cmd-a, c, v, x for text input in native dialogs like file open, save
2 parents 4ecaabb + 60520b7 commit 6cbe86f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

appshell/cefclient_mac.mm

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,34 @@ - (void)setHandlingSendEvent:(BOOL)handlingSendEvent {
7777
}
7878

7979
- (void)sendEvent:(NSEvent*)event {
80+
if ([event type] == NSKeyDown) {
81+
// If mainWindow is the first responder then cef isn't the target
82+
// so let the application event chain handle it intrinsically
83+
if ([[self mainWindow] firstResponder] == [self mainWindow] &&
84+
[event modifierFlags] & NSCommandKeyMask) {
85+
// We've removed cut, copy, paste from the edit menu,
86+
// so we handle those shortcuts explicitly.
87+
SEL theSelector = nil;
88+
NSString *keyStr = [event charactersIgnoringModifiers];
89+
unichar keyChar = [keyStr characterAtIndex:0];
90+
if ( keyChar == 'c') {
91+
theSelector = NSSelectorFromString(@"copy:");
92+
} else if (keyChar == 'v'){
93+
theSelector = NSSelectorFromString(@"paste:");
94+
} else if (keyChar == 'x'){
95+
theSelector = NSSelectorFromString(@"cut:");
96+
} else if (keyChar == 'a'){
97+
theSelector = NSSelectorFromString(@"selectAll:");
98+
} else if (keyChar == 'z'){
99+
theSelector = NSSelectorFromString(@"undo:");
100+
} else if (keyChar == 'Z'){
101+
theSelector = NSSelectorFromString(@"redo:");
102+
}
103+
if (theSelector != nil) {
104+
[[NSApplication sharedApplication] sendAction:theSelector to:nil from:nil];
105+
}
106+
}
107+
}
80108
CefScopedSendingEvent sendingEventScoper;
81109
[super sendEvent:event];
82110
}

0 commit comments

Comments
 (0)