Cocoa Fullscreen problem with keyDown and keyUp
I make fullscreen in this way:
NSRect frame = [[NSScreen mainScreen] frame];
// Instantiate new borderless window
fullscreenWind开发者_JAVA百科ow = [[NSWindow alloc] initWithContentRect:frame
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered defer: NO];
startingWindow = [self window];
[startingWindow setAcceptsMouseMovedEvents:NO];
[startingWindow orderOut:nil];
if(fullscreenWindow != nil)
{
// Set the options for our new fullscreen window
[fullscreenWindow setReleasedWhenClosed: YES];
[fullscreenWindow setAcceptsMouseMovedEvents:YES];
[fullscreenWindow setContentView: self];
[fullscreenWindow makeKeyAndOrderFront:self ];
[fullscreenWindow setLevel: NSPopUpMenuWindowLevel-1];
[fullscreenWindow makeFirstResponder:self];
}
After switching to fullscreen not working keyDown and keyUp. What to do to make it working?
Thanks in advance.
Best regards Chudziutki
You need to override the NSWindow class with your own class that inherits from NSWindow. Then you override the keyDown and keyUp event messages in order to capture them. You then pass these events to whoever needs them.
Why are you doing all this work yourself? Just send your view an -enterFullScreenMode:withOptions:
message.
精彩评论