How to know if a NSWindow is fullscreen in Mac OS X Lion?

前端 未结 4 1247
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-04 05:14

I guess I should check if [NSApplication presentationOptions] contains NSFullScreenModeApplicationPresentationOptions, but how do I achieve that?

4条回答
  •  生来不讨喜
    2021-01-04 05:42

    You need to use an & bitwise operator to test that that option is being used. Not tested but probably something like this:

    - (BOOL) inFullScreenMode {
        NSApplicationPresentationOptions opts = [[NSApplication sharedApplication ] presentationOptions];
        if ( opts & NSApplicationPresentationFullScreen) {
           return YES;
        }
        return NO;
    }
    

    To see if any of your windows are in full screen mode simply check the style mask of the window.

    NSUInteger masks = [someNSWindow styleMask]
    if ( masks & NSFullScreenWindowMask) {
     // Do something
    }
    

提交回复
热议问题