You catch the corresponding mouseDown events
import Cocoa class MyView : NSView { override func mouseDown(theEvent : NSEvent) { println("left mouse") } override func rightMouseDown(theEvent : NSEvent) { println("right mouse") } }
See NSResponder for more details.
Swift 4
import Cocoa class MyView : NSView { override func mouseDown(with theEvent: NSEvent) { print("left mouse") } override func rightMouseDown(with theEvent: NSEvent) { print("right mouse") } }
source share