NSPopover in NSCollectionView (or not)

强颜欢笑 提交于 2019-12-24 02:55:14

问题


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:


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



来源:https://stackoverflow.com/questions/7006102/nspopover-in-nscollectionview-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!