NSPopover in NSCollectionView (or not)

2019-07-21 15:57发布

I have a custom subclass of NSView that is used in an NSCollectionView. The view shows a NSPopover when it is double clicked using the code below:

- (void)mouseDown:(NSEvent *)theEvent {
    [super mouseDown:theEvent];
    if ([theEvent clickCount] == 2) {
        [popover showRelativeToRect:[self bounds] ofView:self preferredEdge:NSMaxYEdge];
    }
}

popover is an IBOutlet (yes it's connected).

This works fine when the view is placed in a window normally, but when the view is in the collection view, it doesn't show.

[popover showRelativeToRect:[self bounds] ofView:self preferredEdge:NSMaxYEdge] is indeed called (I set a breakpoint) and no errors are logged.

Any ideas are appreciated.

1条回答
爷的心禁止访问
2楼-- · 2019-07-21 16:38

Does the collection view accept input? If it does not accept first responder, then your subview won't see the click.

查看更多
登录 后发表回答