diff --git a/CHANGELOG.md b/CHANGELOG.md index f76430cd56..20c0445c88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/CotEditor/Sources/WindowContentViewController.swift b/CotEditor/Sources/WindowContentViewController.swift index 0409d0c1a8..bb0e9fa746 100644 --- a/CotEditor/Sources/WindowContentViewController.swift +++ b/CotEditor/Sources/WindowContentViewController.swift @@ -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 {