Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSView/NSResponder smartMagnify:

I am trying to implement smartMagnify: in an NSView, but it is never called. I have rotate:, magnify:, etc., and they are all being called successfully - what do I need to do to receive this message? I've searched the documentation, which is extremely sparse, and can find no reason why it's not called.

Here's as much as I think is relevant of my code...

class FigOSXLayerView: FigOSXLayerViewBase /* NSView subclass */ {
    var layerViewController: FigOSXLayerVC?
    private var _scale: CGFloat = 1.0

    override func draw(_ dirtyRect: NSRect) {
        self.properties.showSelectionHighlight = true
        self.properties.showAnnotation = true
        self.properties.showPoints = true
        super.draw(dirtyRect)
    }

    // ************************
    // MARK: Zoom, pan, rotate
    // ************************
    override func magnify(with event: NSEvent) {
        self._scale = 1 + event.magnification
        self.layerViewController?.scale(self._scale)
    }

    override func rotate(with event: NSEvent) {
        self.layerViewController?.rotate(CGFloat(event.rotation.toRadians))
    }

    override func scrollWheel(with event: NSEvent) {
        self.layerViewController?.translate(dx: event.deltaX, dy: -event.deltaY)
    }

    override func smartMagnify(with event: NSEvent) {
        Swift.print("Smart magnify") // Not called
    }
    // ...
}

Just through superstition, I have tried setting myself as First Responder, just in case it was something to do with that, but that makes no difference.

like image 906
Grimxn Avatar asked Jan 17 '26 19:01

Grimxn


1 Answers

This event fires when you do double tap with two fingers.

like image 135
Taras Shchybovyk Avatar answered Jan 19 '26 19:01

Taras Shchybovyk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!