简体   繁体   中英

NSPanel to secondary screen when in fullscreen mode

I am trying to get a NSPanel to fill a 2nd monitor when the main window goes into fullscreen mode.

I have the "Full Screen" setting on the panel to "Auxiliary Window" and it will stay on the screen I can drag it onto the other monitor manually and it is fine. However, if I try to do it programmatically, it moves to another Space (although it is maximized on the correct screen).

-(void)windowDidEnterFullScreen:(NSNotification *)notification
{
    NSLog(@"Now in full screen");
    NSArray *screens = [NSScreen screens];

    for (NSScreen *screen in screens) {
        if ([self.window.screen isEqualTo:screen]) {
            NSLog(@"Main Window assigned to screen:%@",screen);
        } else {
            NSLog(@"Assigning auxPanel to screen:%@",screen);
            NSRect screenRect = screen.frame;
            [self.auxPanel setFrame:screenRect display:YES];
        }
    }
}

Thanks in advance.

I'm not sure why the Title Bar needs to be enabled, but I just added:

[self.auxPanel setStyleMask:NSBorderlessWindowMask];

and it seems to work well enough.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM