diff options
author | Gatis Paeglis <gatis.paeglis@digia.com> | 2013-05-27 15:52:26 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-31 12:28:24 +0200 |
commit | 468a37fa2053f91dd64c182b834dc636ff77c7cc (patch) | |
tree | 4e95b3f1cee04a0a00eb0afe7e9d7640bd23ef54 /src/plugins | |
parent | 3523c9e138dc8591619d21f24f60ded27bd7e7e3 (diff) |
Support Mac key equivalent Cmd+Period
On Mac Cmd+Period isa special key combination which never got delived
to Qt application. We can intercept these special keyboard shortcuts in
the performKeyEquivalent function.
Task-number: QTBUG-11386
Change-Id: I680385bde07b2810e8bde86ec9fbbe7e09156c84
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 85f72a4dbb..c7c6c20473 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -113,6 +113,7 @@ QT_END_NAMESPACE - (void)handleKeyEvent:(NSEvent *)theEvent eventType:(int)eventType; - (void)keyDown:(NSEvent *)theEvent; - (void)keyUp:(NSEvent *)theEvent; +- (BOOL)performKeyEquivalent:(NSEvent *)theEvent; - (void)registerDragTypes; - (NSDragOperation)handleDrag:(id <NSDraggingInfo>)sender; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ee6a9616a6..8b157c58e9 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -972,6 +972,23 @@ static QTouchDevice *touchDevice = 0; [self handleKeyEvent:nsevent eventType:int(QEvent::KeyRelease)]; } +- (BOOL)performKeyEquivalent:(NSEvent *)nsevent +{ + NSString *chars = [nsevent charactersIgnoringModifiers]; + + if ([nsevent type] == NSKeyDown && [chars length] > 0) { + QChar ch = [chars characterAtIndex:0]; + Qt::Key qtKey = qt_mac_cocoaKey2QtKey(ch); + // check for Command + Key_Period + if ([nsevent modifierFlags] & NSCommandKeyMask + && qtKey == Qt::Key_Period) { + [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)]; + return YES; + } + } + return [super performKeyEquivalent:nsevent]; +} + - (void)flagsChanged:(NSEvent *)nsevent { ulong timestamp = [nsevent timestamp] * 1000; |