Keep both NSSplitViewController's child controllers in first responder chain

前端 未结 2 1900
挽巷
挽巷 2021-01-03 02:50

I\'ve a document based app with an NSSplitViewController as the main window\'s content view controller. The left pane contains a custom view with controller, which implement

2条回答
  •  清歌不尽
    2021-01-03 03:18

    In Swift 4 you can do the following:

    override func supplementalTarget(forAction action: Selector, sender: Any?) -> Any? {
        for childViewController in childViewControllers {
            if childViewController.responds(to: action) {
    
                return childViewController
            } else {
                guard let supplementalTarget = childViewController.supplementalTarget(forAction: action, sender: sender) else {
                    continue
                }
    
                return supplementalTarget
            }
        }
    
        return super.supplementalTarget(forAction: action, sender: sender)
    }
    

提交回复
热议问题