Creating NSWindow in full screen mode

Is there a way to create NSWindow in full screen? NSWindow has a ToggleFullscreen: selector, but then it creates a window normally and animates it into a full-screen version, which is not what I want. Any other way to do this?

+3
source share
2 answers

First find the screen size

    NSRect screenRect;
    NSArray *screenArray = [NSScreen screens];
    unsigned screenCount = [screenArray count];
    unsigned index  = 0;

    for (index; index < screenCount; index++)
    {
        NSScreen *screen = [screenArray objectAtIndex: index];
        screenRect = [screen visibleFrame];
    }

screenRectcontain the screen size, now create a window and set the size NSWindowto the screen size.

unsigned int styleMask = NSTitledWindowMask 
                           | NSMiniaturizableWindowMask;


  myWindow = [NSWindow alloc];
  myWindow = [myWindow initWithContentRect: screenRect
                       styleMask: styleMask
                       backing: NSBackingStoreBuffered
                       defer: NO];
  [myWindow setTitle: @"This is a test window"];
+3
source
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{

    NSRect frame=[NSScreen mainScreen].frame ;
    [self.window setFrame:frame display:YES animate:YES];
}

a window will open in full screen

+2
source

All Articles