Click through NSView

后端 未结 5 869
后悔当初
后悔当初 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:05

    Here's another approach. It doesn't require creating a new window object and is simpler (and probably a bit more efficient) than the findNextSiblingBelowEventLocation: method above.

    - (NSView *)hitTest:(NSPoint)aPoint
    {
        // pass-through events that don't hit one of the visible subviews
        for (NSView *subView in [self subviews]) {
            if (![subView isHidden] && [subView hitTest:aPoint])
                return subView;
        }
    
        return nil;
    }
    

提交回复
热议问题