Cocoa – Create nswindow in full screen mode

Is there a way to create NSWindow in full screen mode? NSWindow has ToggleFullscreen: selector, but it will create the window normally and animate it as a full screen version, which is not what I want. Other ways of doing this?
First find the screen size

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

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

screenRect contains the screen size, Now create a window and set the NSWindow size to 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"];

Is there a way to create NSWindow in full screen mode? NSWindow has ToggleFullscreen: selector, but it will create the window normally and animate it as a full screen version, which is not what I want. Other ways of doing this?

First find the screen size

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

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

screenRect contains the screen size, now create a window and set the NSWindow size to 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"];

Leave a Comment

Your email address will not be published.