Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

abcdefg12345

macrumors 6502
Original poster
Jul 10, 2013
281
86
I'm trying to toggle off full screen on window 1 and order it out then order window 2 front into the same location and size window 1 used to be, everything is working but after exiting full screen window 1 is not closing.

Code:
- (IBAction)myaction:(id)sender {
    
    // toggl off full screen if in full screen//
    if (([self.window styleMask] & NSFullScreenWindowMask)){
        [self.window toggleFullScreen:nil];
    }
    
    // set the second window size and location to be same as first window
    NSRect frame = [_window frame];
    [self.window2 setFrame:frame display:YES animate:NO];
    
    // open second window and close first window
    [_window2 orderFront:self];
    [_window orderOut:self];
}
 
found a workaround for the issue

it seems that its cancelling out actions that are happening during the time where its switching from full screen to windowed mode

after delaying the action for 1 second it seems to work as expected

Code:
- (IBAction)myaction:(id)sender {
    
    // toggl off full screen if in full screen//
    if (([self.window styleMask] & NSFullScreenWindowMask)){
        [self.window toggleFullScreen:nil];
        [self performSelector:@selector(closewindow1) withObject:nil afterDelay:1];
    }
    
    // set the second window size and location to be same as first window
    NSRect frame = [_window frame];
    [self.window2 setFrame:frame display:YES animate:NO];
    
    // open second window and close first window
    [_window2 orderFront:self];
    [_window orderOut:self];
}

-(void)closewindow1
{
    [_window orderOut:self];
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.