问题
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