In a Mac app how can I open a NSWindow on a specific NSScreen (let's say the second screen)?
This is how I show the window, but it only shows on the main screen
self.windowController = NSStoryboard(name: "Main", bundle: nil).instantiateControllerWithIdentifier("mainWindow") as! NSWindowController
let window = self.windowController.window!
window.makeKeyAndOrderFront(self)
Answers in both Swift and OC are welcome.
Use the class function 'screens' to get an array of all the screens you have. From the array, pick the screen you want your window to appear on. Use the co-ordinates on that window (which are relative to the main window) to make a rect for your new window like this;
[self.window setFrame:CGRectMake(pos.x, pos.y, [mywindow frame].size.width
, [mywindow frame].size.height) display:YES];
where pos is computed from the array of screens and your selectoin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With