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:
parent
3523c9e138
commit
468a37fa20
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user