Skip to content

Commit

Permalink
Enable toolbar/menu items even the focus locates on inspector
Browse files Browse the repository at this point in the history
# Conflicts:
#	CotEditor/Sources/WindowContentViewController.swift
  • Loading branch information
1024jp committed May 21, 2024
1 parent 96a4268 commit 04942f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

### Improvements

- Enable toolbar/menu items for the document editor even when the focus in on the inspector.
- Display a warning if custom setting names contain “:”.
- [dev] Update the build environment to Xcode 15.4.

Expand Down
14 changes: 14 additions & 0 deletions CotEditor/Sources/WindowContentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ final class WindowContentViewController: NSSplitViewController {
}


override func supplementalTarget(forAction action: Selector, sender: Any?) -> Any? {

// reel responders from the ideal first responder in the content view
// for when the actual first responder is on the sidebar/inspector
if let textView = self.documentViewController?.focusedTextView,
let responder = sequence(first: textView, next: \.nextResponder).first(where: { $0.responds(to: action) })
{
responder
} else {
super.supplementalTarget(forAction: action, sender: sender)
}
}


override func validateUserInterfaceItem(_ item: any NSValidatedUserInterfaceItem) -> Bool {

switch item.action {
Expand Down

0 comments on commit 04942f9

Please sign in to comment.