Add to existing content view instead of replacing it

The window border drawing seems to be done by the root content view so it’s best to keep it around (as it may also do other things that we are unaware of).
This commit is contained in:
Allan Odgaard
2013-02-06 14:50:04 +01:00
parent ad750b0b76
commit 642b009ec9

View File

@@ -254,7 +254,6 @@ namespace
self.window = [[NSWindow alloc] initWithContentRect:NSZeroRect styleMask:(NSTitledWindowMask|NSClosableWindowMask|NSResizableWindowMask|NSMiniaturizableWindowMask|NSTexturedBackgroundWindowMask) backing:NSBackingStoreBuffered defer:NO];
self.window.autorecalculatesKeyViewLoop = YES;
self.window.collectionBehavior = NSWindowCollectionBehaviorFullScreenPrimary;
self.window.contentView = self.layoutView;
self.window.delegate = self;
self.window.releasedWhenClosed = NO;
[self.window setContentBorderThickness:0 forEdge:NSMaxYEdge]; // top border
@@ -262,6 +261,11 @@ namespace
[self.window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
[self.window setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge];
[self.layoutView setTranslatesAutoresizingMaskIntoConstraints:NO];
[self.window.contentView addSubview:self.layoutView];
[self.window.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view]|" options:0 metrics:nil views:@{ @"view" : self.layoutView }]];
[self.window.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[view]|" options:0 metrics:nil views:@{ @"view" : self.layoutView }]];
[OakWindowFrameHelper windowFrameHelperWithWindow:self.window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userDefaultsDidChange:) name:NSUserDefaultsDidChangeNotification object:[NSUserDefaults standardUserDefaults]];