Merge pull request #41 from luosheng/popover-acting-like-key

Popover window should act like a key window.
This commit is contained in:
Danny Greg 2012-10-25 05:49:33 -07:00
Родитель 9f90894c0a 9694c86344
Коммит 7391dc0c44
1 изменённых файлов: 20 добавлений и 2 удалений

Просмотреть файл

@ -13,6 +13,14 @@
//***************************************************************************
// We'll use this as RBLPopover's backing window. Since it's borderless, we
// just override the `isKeyWindow` method to make it act like a key window.
@interface RBLPopoverWindow : NSWindow
@end
//***************************************************************************
@interface RBLPopoverBackgroundView ()
@property (nonatomic) CGRect screenOriginRect;
@ -32,7 +40,7 @@ static NSTimeInterval const RBLPopoverDefaultFadeDuration = 0.3;
@interface RBLPopover ()
// The window we are using to display the popover.
@property (nonatomic, strong) NSWindow *popoverWindow;
@property (nonatomic, strong) RBLPopoverWindow *popoverWindow;
// The identifier for the event monitor we are using to watch for mouse clicks
// outisde of the popover.
@ -87,6 +95,16 @@ static NSTimeInterval const RBLPopoverDefaultFadeDuration = 0.3;
//***************************************************************************
@implementation RBLPopoverWindow
- (BOOL)isKeyWindow {
return YES;
}
@end
//***************************************************************************
@implementation RBLPopover
- (instancetype)initWithContentViewController:(NSViewController *)viewController {
@ -247,7 +265,7 @@ static NSTimeInterval const RBLPopoverDefaultFadeDuration = 0.3;
self.contentViewController.view.autoresizingMask = (NSViewWidthSizable | NSViewHeightSizable);
self.contentViewController.view.frame = contentViewFrame;
[self.backgroundView addSubview:self.contentViewController.view];
self.popoverWindow = [[NSWindow alloc] initWithContentRect:popoverScreenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
self.popoverWindow = [[RBLPopoverWindow alloc] initWithContentRect:popoverScreenRect styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:NO];
self.popoverWindow.hasShadow = YES;
self.popoverWindow.releasedWhenClosed = NO;
self.popoverWindow.opaque = NO;