I would like to display an NSWindow
created in a storyboard full screen on a secondary monitor. The below code results in the window being displayed on the primary screen/main screen. The Y origin is ok but the X origin is 0 where it should be -1680. The code below worked before Yosemite.
NSScreen *screen = [[NSScreen screens] objectAtIndex:2];
NSRect mainDisplayRect = [screen frame];
[PresenterWindow setFrame: mainDisplayRect display:YES animate:YES];
[PresenterWindow makeKeyAndOrderFront:sender];
[PresenterWindow setLevel: CGShieldingWindowLevel()];
I had also tried the following with the same result:
[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, [screen frame].size.width, [screen frame].size.height)
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO
screen:screen];
Please advise how I can fix this.
I've tried solutions from some other questions:
- Cocoa Open a fullscreen window on the second screen maintaining the app visible on the first - did not work - same result.
- Display os x window full screen on secondary monitor using Cocoa - nope - neither with
enterFullScreenMode:withOptions:
method of NSView.
I have some new observations:
If i activate the "Launch At Startup" in the storyboard for my NSWindow
the window is viewed fullscreen on my secondary monitor. If i then do a orderOut
and run the above code the window is viewed in correct size but on my primary/main screen. The window is not activated to "Release When Close". So when I deactivate "Launch At Startup" the window is again viewed in the primary/main screen with the size of the secondary screen.