mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 20:50:44 +00:00
Handle window becoming key
This commit is contained in:
parent
4b13050e70
commit
ba92e90a85
1 changed files with 28 additions and 1 deletions
|
@ -39,6 +39,10 @@
|
|||
#import "AppKit/NSStoryboard.h"
|
||||
#import "AppKit/NSGraphics.h"
|
||||
|
||||
|
||||
static NSNotificationCenter *nc = nil;
|
||||
|
||||
|
||||
// Popover private classes
|
||||
|
||||
@interface GSPopoverView : NSView
|
||||
|
@ -130,8 +134,16 @@
|
|||
/* Class */
|
||||
@implementation NSPopover
|
||||
|
||||
/* Properties */
|
||||
+ (void) initialize
|
||||
{
|
||||
if ([self class] == [NSPopover class])
|
||||
{
|
||||
nc = [NSNotificationCenter defaultCenter];
|
||||
[self setVersion: 0];
|
||||
}
|
||||
}
|
||||
|
||||
/* Properties */
|
||||
- (void) setAnimates: (BOOL)flag
|
||||
{
|
||||
_animates = flag;
|
||||
|
@ -240,6 +252,16 @@
|
|||
[_realPanel setDelegate:nil];
|
||||
}
|
||||
|
||||
- (void) _handleWindowDidBecomeKey: (NSNotification *)notification
|
||||
{
|
||||
id obj = [notification object];
|
||||
|
||||
if (obj != _realPanel)
|
||||
{
|
||||
[self close];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) showRelativeToRect: (NSRect)positioningRect
|
||||
ofView: (NSView *)positioningView
|
||||
preferredEdge: (NSRectEdge)preferredEdge
|
||||
|
@ -268,6 +290,11 @@
|
|||
[_realPanel setDelegate: self];
|
||||
[_realPanel setContentView: view];
|
||||
}
|
||||
|
||||
[nc addObserver: self
|
||||
selector: @selector(_handleWindowDidBecomeKey:)
|
||||
name: NSWindowDidBecomeKeyNotification
|
||||
object: nil];
|
||||
|
||||
screenRect = [[positioningView window] convertRectToScreen:positioningRect];
|
||||
windowFrame = [_realPanel frame];
|
||||
|
|
Loading…
Reference in a new issue