How can one detect two finger zoom gestures on MacBook trackpad? (within a selected NSView)
var zoom:CGFloat = 0
override func magnify(with event: NSEvent) {
    super.magnify(with: event)
    if(event.phase == .changed){
        zoom += event.deltaZ
    }else if(event.phase == .began){
        zoom = 0//reset
    }else if(event.phase == .ended){
        //Swift.print("zoom: " + "\(zoom)")
        var dir:Int
        if(zoom < -100){
            Swift.print("zoom out")
            dir = 1
        }else if(zoom > 100){
            Swift.print("zoom in")
            dir = -1
        }else{
            Swift.print("no zoom")
            dir = 0
        }
    }
}
It detects if a zoom gesture has occurred +-100 deltaZ (Aka Pinch in/out to zoom)
More info and research surrounding this approach:
http://eon.codes/blog/2016/02/10/Gesture-research/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With