title: How to handle double monitors in ObjectiveC?
body: <p>I'm working with a Cordova Mac application and I can see weird behaviours when I have more than one monitor plugged in.</p>
  
  <p>I'm using a Point to center the view which is on the Icon on the Menubar. However, when I work with two monitors, you have to click several times to actually get the right position.</p>
  
  <p>This is the code to show the window:</p>
  
  <pre><code>- (void) showPanel
  {
      NSRect statusFrame = [[self.statusItem valueForKey:@"window"] frame];
      NSRect winFrame = [self.window frame];
      NSRect screenFrame = [[self.window screen] frame];
  
      NSPoint p = NSMakePoint(statusFrame.origin.x, screenFrame.size.height - 32);
      if (p.x &gt; (screenFrame.size.width - winFrame.size.width)) {
          p.x = screenFrame.size.width - winFrame.size.width - 30;
      }
  
      [self.window setFrameTopLeftPoint:p];
      [self.window setIsVisible:YES];
      [NSApp activateIgnoringOtherApps:YES];
      [self.window makeKeyAndOrderFront:self];
  }
  </code></pre>
  
  <p>I'm a total newbie when it comes to ObjectiveC so I'm not sure is there any considerations I should have in mind for this kind of scenarios.</p>