title: NSWindow is not receiving any notification when it loses focus
body: <p>I have a custom NSWindow class that has the following methods:</p>
  
  <pre><code>- (void)setupWindowForEvents{
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignMainNotification object:self];
      [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:self];
  }
  
  -(void)windowDidResignKey:(NSNotification *)note {
      NSLog(@"notification");
      [self close];
  }
  </code></pre>
  
  <p>I call <code>[_window setupWindowForEvents];</code> but the <code>windowDidResignKey</code> never gets called.
  <br>This is how I call my NSWindow: when the status bar item is clicked I <code>makeKeyAndOrderFront</code> and the Window is displayed right beneath the status bar item, like this:<img src="https://i.stack.imgur.com/piCj2.png" alt="enter image description here"></p>
  
  <p>Any ideas why the I don't get any notification when the window loses focus? I've used both <code>NSWindowDidResignMainNotification</code> and <code>NSWindowDidResignKeyNotification</code> to see if any of these worked, but none is working.</p>