From 6f94664428f325a92fdf90e869569240d54678f6 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Tue, 24 Jan 2017 23:10:50 +0200 Subject: [PATCH] Close Open Panels if a document is opened via other means --- Cocoa/Document.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Cocoa/Document.m b/Cocoa/Document.m index d0c23d7c..397f7ccb 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -275,6 +275,14 @@ static void printImage(GB_gameboy_t *gb, uint32_t *image, uint8_t height, - (void)windowControllerDidLoadNib:(NSWindowController *)aController { [super windowControllerDidLoadNib:aController]; + + /* Close Open Panels, if any */ + for (NSWindow *window in [[NSApplication sharedApplication] windows]) { + if ([window isKindOfClass:[NSOpenPanel class]]) { + [(NSOpenPanel *)window cancel:self]; + } + } + self.consoleOutput.textContainerInset = NSMakeSize(4, 4); [self.view becomeFirstResponder]; self.view.shouldBlendFrameWithPrevious = ![[NSUserDefaults standardUserDefaults] boolForKey:@"DisableFrameBlending"];