How to receive keyboard events for a NSView after exiting fullscreen mode?
-
12-11-2019 - |
Pregunta
I subclass an NSView and start full screen mode when the application finished launching. The view is available as the property fooView
in the application delegate.
// AppDelegate.m
- (void)applicationDidFinishLaunching:(NSNotification*)notification {
[[self window] makeKeyAndOrderFront:self];
[[self fooView] enterFullScreenMode:[NSScreen mainScreen] withOptions:nil];
}
The class FooView
itself implements the following functions.
// FooView.m
- (void)keyDown:(NSEvent*)event {
NSLog(@"%@ %@ - %@", self.className, NSStringFromSelector(_cmd), event);
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
}
- (void)cancelOperation:(id)sender {
NSLog(@"%@ %@ - %@", self.className, NSStringFromSelector(_cmd), sender);
[self exitFullScreenModeWithOptions:nil];
}
After leaving the fullscreen mode, the view no longer receives keyboard events. Why?
Edit:
It seems to have something to do with how I exit the fullscreen mode. When I click into the view (not the window) the keyDown:
and cancelOperation:
do respond in the following.
No hay solución correcta
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow