diff --git a/Frameworks/DocumentWindow/src/DocumentController.mm b/Frameworks/DocumentWindow/src/DocumentController.mm index 2b50cb0e..02935f42 100644 --- a/Frameworks/DocumentWindow/src/DocumentController.mm +++ b/Frameworks/DocumentWindow/src/DocumentController.mm @@ -287,16 +287,17 @@ namespace NSUInteger windowStyle = (NSTitledWindowMask|NSClosableWindowMask|NSResizableWindowMask|NSMiniaturizableWindowMask|NSTexturedBackgroundWindowMask); self.window = [[NSWindow alloc] initWithContentRect:[NSWindow contentRectForFrameRect:[self frameRectForNewWindow] styleMask:windowStyle] styleMask:windowStyle backing:NSBackingStoreBuffered defer:NO]; - self.window.autorecalculatesKeyViewLoop = YES; - self.window.collectionBehavior = NSWindowCollectionBehaviorFullScreenPrimary; - self.window.delegate = self; - self.window.releasedWhenClosed = NO; + self.window.collectionBehavior = NSWindowCollectionBehaviorFullScreenPrimary; + self.window.delegate = self; + self.window.releasedWhenClosed = NO; [self.window setContentBorderThickness:0 forEdge:NSMaxYEdge]; // top border [self.window setContentBorderThickness:0 forEdge:NSMinYEdge]; // bottom border [self.window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge]; [self.window setAutorecalculatesContentBorderThickness:NO forEdge:NSMinYEdge]; OakAddAutoLayoutViewsToSuperview(@[ self.layoutView ], self.window.contentView); + OakSetupKeyViewLoop(@[ self.layoutView ], NO); + self.window.initialFirstResponder = self.textView; [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 }]]; diff --git a/Frameworks/DocumentWindow/src/ProjectLayoutView.mm b/Frameworks/DocumentWindow/src/ProjectLayoutView.mm index 5a3d6f98..24d2b1b7 100644 --- a/Frameworks/DocumentWindow/src/ProjectLayoutView.mm +++ b/Frameworks/DocumentWindow/src/ProjectLayoutView.mm @@ -64,19 +64,31 @@ NSString* const kUserDefaultsHTMLOutputSizeKey = @"htmlOutputSize"; return newView; } -- (void)setTabBarView:(OakTabBarView*)aTabBarView { _tabBarView = (OakTabBarView*)[self replaceView:_tabBarView withView:aTabBarView]; } -- (void)setDocumentView:(NSView*)aDocumentView { _documentView = [self replaceView:_documentView withView:aDocumentView]; } +- (void)updateKeyViewLoop +{ + OakSetupKeyViewLoop(@[ + _tabBarView ?: [NSNull null], + _documentView ?: [NSNull null], + _htmlOutputView ?: [NSNull null], + _fileBrowserView ?: [NSNull null], + ], NO); +} + +- (void)setTabBarView:(OakTabBarView*)aTabBarView { _tabBarView = (OakTabBarView*)[self replaceView:_tabBarView withView:aTabBarView]; [self updateKeyViewLoop]; } +- (void)setDocumentView:(NSView*)aDocumentView { _documentView = [self replaceView:_documentView withView:aDocumentView]; [self updateKeyViewLoop]; } - (void)setHtmlOutputView:(NSView*)aHtmlOutputView { _htmlOutputDivider = [self replaceView:_htmlOutputDivider withView:(aHtmlOutputView ? (_htmlOutputOnRight ? OakCreateVerticalLine([NSColor controlShadowColor]) : OakCreateHorizontalLine([NSColor colorWithCalibratedWhite:0.500 alpha:1])) : nil)]; _htmlOutputView = [self replaceView:_htmlOutputView withView:aHtmlOutputView]; + [self updateKeyViewLoop]; } - (void)setFileBrowserView:(NSView*)aFileBrowserView { _fileBrowserDivider = [self replaceView:_fileBrowserDivider withView:aFileBrowserView ? OakCreateVerticalLine([NSColor controlShadowColor]) : nil]; _fileBrowserView = [self replaceView:_fileBrowserView withView:aFileBrowserView]; + [self updateKeyViewLoop]; } - (void)setFileBrowserOnRight:(BOOL)flag diff --git a/Frameworks/OakFileBrowser/src/OakFileBrowser.mm b/Frameworks/OakFileBrowser/src/OakFileBrowser.mm index 3f43aea2..eb2aa901 100644 --- a/Frameworks/OakFileBrowser/src/OakFileBrowser.mm +++ b/Frameworks/OakFileBrowser/src/OakFileBrowser.mm @@ -259,6 +259,7 @@ static NSMutableSet* SymmetricDifference (NSMutableSet* aSet, NSMutableSet* anot }; OakAddAutoLayoutViewsToSuperview([views allValues], _view); + OakSetupKeyViewLoop(@[ _view, _headerView, _outlineView, _actionsView ], NO); [_view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[browser(==header,==actionsDivider,==actions)]|" options:0 metrics:nil views:views]]; [_view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[header][browser][actionsDivider][actions]|" options:NSLayoutFormatAlignAllLeft metrics:nil views:views]]; diff --git a/Frameworks/OakFileBrowser/src/ui/OFBActionsView.mm b/Frameworks/OakFileBrowser/src/ui/OFBActionsView.mm index fcc7271c..2dab0be0 100644 --- a/Frameworks/OakFileBrowser/src/ui/OFBActionsView.mm +++ b/Frameworks/OakFileBrowser/src/ui/OFBActionsView.mm @@ -58,6 +58,7 @@ static NSButton* OakCreateImageButton (NSImage* image) }; OakAddAutoLayoutViewsToSuperview([views allValues], self); + OakSetupKeyViewLoop(@[ self, _createButton, _actionsPopUpButton, _reloadButton, _searchButton, _favoritesButton, _scmButton ], NO); [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-3-[create(==24)]-1-[divider]-5-[actions(==30)]-(>=8)-[reload(==22,==search,==favorites,==scm)][search]-1-[favorites]-2-[scm]-(12)-|" options:0 metrics:nil views:views]]; [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[create(==divider,==actions,==reload,==search,==favorites,==scm)]|" options:0 metrics:nil views:views]]; diff --git a/Frameworks/OakFileBrowser/src/ui/OFBHeaderView.mm b/Frameworks/OakFileBrowser/src/ui/OFBHeaderView.mm index 6e8f42bb..2424d408 100644 --- a/Frameworks/OakFileBrowser/src/ui/OFBHeaderView.mm +++ b/Frameworks/OakFileBrowser/src/ui/OFBHeaderView.mm @@ -130,6 +130,7 @@ static NSPopUpButton* OakCreateFolderPopUpButton () }; OakAddAutoLayoutViewsToSuperview([views allValues], self); + OakSetupKeyViewLoop(@[ self, _folderPopUpButton, _goBackButton, _goForwardButton ], NO); [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-(-3)-[folder(>=75)]-(3)-[divider]-(2)-[back(==22)]-(2)-[forward(==back)]-(3)-|" options:0 metrics:nil views:views]]; [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[bottomDivider]|" options:0 metrics:nil views:views]]; diff --git a/Frameworks/OakTextView/src/OTVStatusBar.mm b/Frameworks/OakTextView/src/OTVStatusBar.mm index 244e9f1c..024b7a15 100644 --- a/Frameworks/OakTextView/src/OTVStatusBar.mm +++ b/Frameworks/OakTextView/src/OTVStatusBar.mm @@ -110,6 +110,7 @@ static NSMenuItem* OakCreateIndentMenuItem (NSString* title, SEL action, id targ }; OakAddAutoLayoutViewsToSuperview([views allValues], self); + OakSetupKeyViewLoop(@[ self, _grammarPopUp, _tabSizePopUp, _bundleItemsPopUp, _symbolPopUp, _macroRecordingButton ], NO); [self.selectionField setContentHuggingPriority:NSLayoutPriorityDefaultLow forOrientation:NSLayoutConstraintOrientationHorizontal]; [self.selectionField setContentCompressionResistancePriority:NSLayoutPriorityDefaultLow+2 forOrientation:NSLayoutConstraintOrientationHorizontal]; diff --git a/Frameworks/OakTextView/src/OakDocumentView.mm b/Frameworks/OakTextView/src/OakDocumentView.mm index a3ee83ec..873c8ca4 100644 --- a/Frameworks/OakTextView/src/OakDocumentView.mm +++ b/Frameworks/OakTextView/src/OakDocumentView.mm @@ -138,6 +138,7 @@ private: statusBar.target = self; OakAddAutoLayoutViewsToSuperview(@[ gutterScrollView, gutterDividerView, textScrollView, statusDividerView, statusBar ], self); + OakSetupKeyViewLoop(@[ self, textView, statusBar ], NO); document::document_ptr doc = document::from_content("", "text.plain"); // file type is only to avoid potential “no grammar” warnings in console doc->set_custom_name("null document"); // without a name it grabs an ‘untitled’ token