开发者

NSView mouse events after adding subview

开发者 https://www.devze.com 2023-02-23 22:19 出处:网络
After I add a subview to NSView, my mouse events respond to the area of NSView minus the addedSubVIew. How can I avoid that? I want it 开发者_如何学Goto respond on all of the superview.

After I add a subview to NSView, my mouse events respond to the area of NSView minus the addedSubVIew. How can I avoid that? I want it 开发者_如何学Goto respond on all of the superview. Thanks.


You can also implement the hitTest: method in the container view.

- (NSView *) hitTest: (NSPoint) aPoint {
    return [super hitTest:aPoint] ? self : nil;
}

Now only the container view can receive the mouse events.


You can override the subviews [NSView hitTest:] method and return the superview.

- (NSView *) hitTest: (NSPoint) aPoint {
    return [self superview];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号