Oliver Koehler Oliver Koehler - 4 years ago 189
Swift Question

How to catching doubleClick events from NSOutlineView in ViewController?

I am trying to catch doubleClick events from my NSOutlineView to be passed to my ViewController. My idea is to catch doubleClick events and to get the selected row from my OutlineView
What I did so far was subclassing the NSOutlineView in order to overwrite mouseDown

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

That works well however I don't know how to pass this event to my ViewController. The ViewController is already implementing the NSOutlineViewDelegate protocol.

I guess that the solution is not far away but somehow I am stuck.

Answer Source

UPDATED Although you can set up NSGestureRecognizer for single click and NSClickGestureRecognizer for double clicks in OSX, You should probably be using the doubleAction property of the NSOutlineView directly.

Here's an example of how to set it up enter image description here

This comes from a another of the Wenderlich tutorials, and there is a good discussion on SO already

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download