• 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
Re: Position a window in center & under the menubar.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Position a window in center & under the menubar.


  • Subject: Re: Position a window in center & under the menubar.
  • From: Paul Lynch <email@hidden>
  • Date: Wed, 14 Jun 2006 15:48:38 +0100


On 12 Jun 2006, at 17:07, Mohsan Khan wrote:

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

Use -visibleFrame.

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?

The doc comments on visibleFrame should help.


Paul _______________________________________________ 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
References: 
 >Position a window in center & under the menubar. (From: Mohsan Khan <email@hidden>)

  • Prev by Date: Re: Transparent white NSView (Solved)
  • Next by Date: Re: Friendly hint with Font Manager and IB. (Was: Re: Doc App - Errors closing an document.)
  • Previous by thread: NSFormCell unique entries
  • Next by thread: String to Integer conversion and vice versa
  • Index(es):
    • Date
    • Thread