开发者

Cocoa Fullscreen problem with keyDown and keyUp

开发者 https://www.devze.com 2023-01-27 01:11 出处:网络
I make fullscreen in this way: NSRect frame = [[NSScreen mainScreen] frame]; // Instantiate new borderless window

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消