NSTextField click-through?

后端 未结 2 880
半阙折子戏
半阙折子戏 2021-01-18 01:44

I have a static NSTextField that overlays a large error message in my OS X app. I\'m trying to get it to allow the user to click controls beneath it.

In

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-18 02:06

    The only way I have found to make an object transparent to the click is to subclass that object (in your case the NSTextField) and override the hitTest method returning nil. This way that NSTextField will not respond to the click so the NSView below will respond to the click.

    - (NSView*)hitTest:(NSPoint)aPoint
    {
        return nil;
    }
    

提交回复
热议问题