Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to move NSWindow to a particular screen?

In my app I need to be able to move my app's windows between the screens programmatically. I'm working on my MacBookPro and I'm connected to DELL monitor. So what I want to do is to have a method that would move my app's window from my laptop screen to the external DELL one.

Does anyone know how to achieve it?

Any help is highly appreciated!

like image 312
Eugene Gordin Avatar asked May 20 '13 21:05

Eugene Gordin


1 Answers

[NSScreen screens] gives you an array of NSScreens. The screen at index 0 is the one that's got your menu on.

So pick the other screen from the array, find it's visibleFrame and change the frame of your window to go inside it.

like image 112
Steve Waddicor Avatar answered Sep 20 '22 11:09

Steve Waddicor