mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 04:54:35 +00:00
The combination CTRL + Tab is specially handled by OSX/Cocoa text input method. At least two solutions exists([here](https://bugreports.qt.io/browse/QTBUG-8596?focusedCommentId=321526&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-321526) and (there)[https://codereview.qt-project.org/#/c/161214/1/src/plugins/platforms/cocoa/qnsview.mm]). However, the first one use a private/undocumented API. The second is then used.
This commit is contained in:
parent
5afcd0981b
commit
97db21f206
@ -643,6 +643,36 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
|
|||||||
[super updateTrackingAreas];
|
[super updateTrackingAreas];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL)performKeyEquivalent:(NSEvent *)nsevent
|
||||||
|
{
|
||||||
|
// At the moment the only reason we define this method
|
||||||
|
// is Ctrl-tab key event never reaching any view at all.
|
||||||
|
// After -performKeyEquivalent: returns NO on all responders,
|
||||||
|
// we receve Ctrl-tab in our QNSWindow's -sendEvent:,
|
||||||
|
// but somehow it never reaches QNSView's -keyDown:.
|
||||||
|
// Apparently, it's treated in a special (and undocumented)
|
||||||
|
// way by Cocoa. 'Illegal' but really nice, clear and safe solution
|
||||||
|
// would be to define _wantsKeyDownForEvent, but it's a
|
||||||
|
// private/undocumented API.
|
||||||
|
if ([[self window] firstResponder] == self)
|
||||||
|
{
|
||||||
|
const NSUInteger modifierFlags = [nsevent modifierFlags];
|
||||||
|
NSString *chs = [nsevent charactersIgnoringModifiers];
|
||||||
|
if (modifierFlags & NSControlKeyMask)
|
||||||
|
{
|
||||||
|
if ([chs characterAtIndex:0] == NSTabCharacter)
|
||||||
|
{
|
||||||
|
if (![[NSApp mainMenu] performKeyEquivalent:nsevent])
|
||||||
|
{
|
||||||
|
[self keyDown:nsevent];
|
||||||
|
}
|
||||||
|
return YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)keyDown:(NSEvent *)event
|
- (void)keyDown:(NSEvent *)event
|
||||||
{
|
{
|
||||||
const int key = translateKey([event keyCode]);
|
const int key = translateKey([event keyCode]);
|
||||||
|
Loading…
Reference in New Issue
Block a user