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.
The problem was that the window containing the view did receive any keyboard events. One needs to make the window the first responder after leaving the full screen mode.
- (void)cancelOperation:(id)sender {
NSLog(@"%@ %@ - %@", self.className, NSStringFromSelector(_cmd), sender);
[self exitFullScreenModeWithOptions:nil];
[self.window makeFirstResponder:self];
}