(Note: question has been asked before, with less-than-conclusive results over a year ago. Hopefully we know a bit more now and can solve it?)
I'm trying to make an NSPopover display over an NSCollectionItem when it is double-clicked. My NSCollectionView is set up properly and receives input.
(If I copy-paste the code to other NSView subclasses, it works just fine. There is something with NSCollectionView that appears to be messing things up.)
The code:
BIECollectionViewItem.h
#import <Cocoa/Cocoa.h>
@class BIEAppDelegate;
@interface BIECollectionViewItem : NSView {
IBOutlet NSPopover *popover;
}
@end
BIECollectionViewItem.m
#import "BIECollectionViewItem.h"
@implementation BIECollectionViewItem
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect
{
// Drawing code here.
}
- (void)mouseDown:(NSEvent *)theEvent {
[super mouseDown: theEvent];
if([theEvent clickCount] == 2){
[popover showRelativeToRect: [self bounds] ofView: self preferredEdge: NSMaxYEdge];
}
}
@end
If I add a log statement in the mouseDown event, I can confirm that the event is being fired. However, the NSPopover refuses to appear!
Does anyone know how to get an NSPopover to appear over an NSCollectionView?