Click through NSView

后端 未结 5 990
后悔当初
后悔当初 2021-01-02 04:30

I have an NSView containing multiple subviews. One of those subviews is transparent and layered on top.

I need to be able to click through this view dow

5条回答
  •  醉话见心
    2021-01-02 05:03

    Here's a Swift 5 version of figelwump's answer:

    public override func hitTest(_ point: NSPoint) -> NSView? {
        // pass-through events that don't hit one of the visible subviews
        return subviews.first { subview in
            !subview.isHidden && nil != subview.hitTest(point)
        }
    }
    

提交回复
热议问题