How to change NSScreen, NSWindow will appear

I have an application that will load several windows depending on which button is clicked. All but one of them are open on the main screen (the screen on which the main window is open). One of them (preferences window) opens on the first screen (screen with a menu bar). I can not understand how this is done, is there a way to change the screen that NSWindow opens?

+3
source share
2 answers

I could not get too much response to work. What I ended up was subclassing NSWindow and then overriding constrainFrameRect: toScreen :. This will automatically open a new window on the "main screen" of the application.

- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
{
    AppDelegate *delegate = [[NSApplication sharedApplication] delegate];
    return [super constrainFrameRect:frameRect toScreen:delegate.window.screen];
}
+4
source

, , initWithFrame, NSScreen.

+1

All Articles