title: Getting mouse position from a custom nsview
body: <p>I'm trying to get the mouse location relative to the nsview.</p>
  
  <p>There are at least two methods that I know of:</p>
  
  <pre><code>NSPoint mousePosition = [self.window convertScreenToBase:[NSEvent mouseLocation]];
  </code></pre>
  
  <p>And</p>
  
  <pre><code>NSPoint mousePosition = [self.window mouseLocationOutsideOfEventStream];
  </code></pre>
  
  <p>The problem with both of those methods is that self.view is null. I'm adding this view from a view controller that itself was added by another view controller. I would like to know if it's possible to get the toplevel window starting from a nsview that can be many levels below.</p>
  
  <p>Edit: of course I can use: </p>
  
  <pre><code>NSWindow *window = [self valueForKeyPath:@"delegate.delegate.view.window"];
  </code></pre>
  
  <p>But there must be a better way.</p>