2

我有一个自定义子类NSView,用于NSCollectionView. NSPopover当使用以下代码双击视图时,该视图会显示:

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

popover是一个IBOutlet(是的,它已连接)。

当视图正常放置在窗口中时,这可以正常工作,但是当视图位于集合视图中时,它不会显示。

[popover showRelativeToRect:[self bounds] ofView:self preferredEdge:NSMaxYEdge]确实被调用(我设置了一个断点)并且没有记录错误。

任何想法表示赞赏。

4

1 回答 1

0

集合视图是否接受输入?如果它不接受第一响应者,那么您的子视图将看不到点击。

于 2011-12-23T20:39:26.763 回答