Search code examples
objective-cswiftcocoaikimageview

Prevent IKImageView from handling gestures


I have class Canvas and another custom view CanvasItem both subclasses of NSView. The CanvasItem has a IKImageView subview.

Canvas overrides magnifyWithEvent to react to the gesture. Everything works fine except the case when the gesture is done on one of the CanvasItems then the IKImageView handles the event and zooms the image instead of passing it up the view hierarchy. Is here a way to prevent IKImageView from handling gestures?

I tried setting editable to false but with no effect.


Solution

  • Found a solution that works for me. In the end it was quite simple: I created a new subclass of IKImageView overwrote the magnifyWithEvent and passed the event to the next responder. And then used this class instead of the original IKImageView.

    class MyIKImageView : IKImageView {
        override func magnifyWithEvent(event: NSEvent) {
            self.nextResponder?.magnifyWithEvent(event)
        }
    }