如何在 ViewController 中从 NSOutlineView 捕获 doubleClick 事件?

How to catching doubleClick events from NSOutlineView in ViewController?

我正在尝试从我的 NSOutlineView 中捕获 doubleClick 事件以传递给我的 ViewController。我的想法是捕获 doubleClick 事件并从我的 OutlineView 中获取选定的行 到目前为止我所做的是子类化 NSOutlineView 以覆盖 mouseDown

override func mouseDown(with event: NSEvent) {
   super.mouseDown(with: event)
   if event.clickCount >= 2 {
      ... 
   }
}

效果很好,但我不知道如何将此事件传递给我的 ViewController。 ViewController 已经实现了 NSOutlineViewDelegate 协议。

我想解决方案不远了,但不知何故我被卡住了。

已更新 尽管您可以在 OSX 中为单击设置 NSGestureRecognizer 并为双击设置 NSClickGestureRecognizer,但您可能应该使用 [=13] 的 doubleAction 属性 =]直接。

这是一个如何设置的例子

这来自另一个 Wenderlich tutorials, and there is a good discussion on SO already