• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Position a window in center & under the menubar.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Position a window in center & under the menubar.


  • Subject: Position a window in center & under the menubar.
  • From: Mohsan Khan <email@hidden>
  • Date: Mon, 12 Jun 2006 18:07:16 +0200

Hi

This is my first Cocoa post ever!
I just started with Cocoa, Cocoa rules!

anyway...


I have a window which I want in center of the screen and under the menubar with some offset from the menubar.



------------------------------------------------------------------------ ------------
// center the window
[mMainWindow center];


// place at top, under the menu
NSRect screenRect = [[NSScreen mainScreen] frame]; // get the screen rect of our main display
NSRect windowRect = [mMainWindow frame];
NSPoint p = windowRect.origin;


p.y = screenRect.size.height - [NSMenuView menuBarHeight] -20; // screen size from bottom to top

[mMainWindow setFrameOrigin: p];
------------------------------------------------------------------------ ------------



This puts the window in center just under the menubar, but the -20 offset does not apply.
The offset applies if I set -70, then there seems to be a 10 pixel offset from the menubar.


My question, what am I doing wrong here?
Why doesn't -20 apply?





Yours sincerely,
Mohsan Khan.
_______________________________________________________________
Programmer, Animator, Musician
www.xybernic.com
There is no place like 127.0.0.1.
If everybody would give everybody a million would everybody be millionaires?
Nothing has got to do with anything, but something has got to do with everything.



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Position a window in center & under the menubar.
      • From: Paul Lynch <email@hidden>
    • NSFormCell unique entries
      • From: Neto <email@hidden>
  • Prev by Date: Re: NSTreeController woes... NSZombie at doc closed
  • Next by Date: NSFormCell unique entries
  • Previous by thread: Re: Write File with NSData
  • Next by thread: NSFormCell unique entries
  • Index(es):
    • Date
    • Thread