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>
This commit is contained in:
Gatis Paeglis 2013-05-27 15:52:26 +02:00 committed by The Qt Project
parent 3523c9e138
commit 468a37fa20
2 changed files with 18 additions and 0 deletions

View File

@ -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;

View File

@ -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;