7

Editing my nib for a document-based Cocoa application, I see that when I have a window or panel selected, Xcode lets me set its “initial position”:

Screenshot of a window in the nib, selected, and the “Initial position” pane in the Size Inspector.

This is separate from the window's Frame, which is above it, so what is this?

What uses the “initial position”, and what do the two pop-up menus and their possible values mean?

When I run my app and my document creates the NSWindowController for this nib (the second of two), the window appears cascaded from the main document window, rather than at the initial position. Is this because my app is document-based (i.e., the “Initial Position” would be used by a window not owned by a document), or is there some other reason?

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370

2 Answers2

5

The initial position is the position in the screen where the window will appear, by default. And the popups control how this position is altered if the user's screen size is different than yours.

Imagine the screen is a giant NSView, and your window is positioned within it. Initial position is the frame origin, and the popups are your autoresizing mask.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • My window is appearing in the top-left, though. – Peter Hosey Oct 17 '11 at 21:38
  • It's probably because you're document-based. Document windows tend to cascade instead of appearing in one fixed position. The "initial position" value is more useful for windows that your application only ever has one of, such as the About box or the Preferences panel. – Lily Ballard Oct 17 '11 at 21:53
  • Do you have any further insight at what time AppKit applies those values? I'm asking because I'm trying to figure out what would be a good place to set an initial position programatically instead of using IB. – Klaas Jun 01 '16 at 11:46
  • @Klaas My assumption would be that by the time `awakeFromNib` is invoked it's already set, but I don't know for sure. – Lily Ballard Jun 02 '16 at 18:31
0

I just changed the initial position to 0, 0 it fixed the issue right away. It seems it wants it to start on the lower left corner. I played around with other settings, adjusting the width and height properties.

http://prntscr.com/8unin6

Vyache
  • 381
  • 4
  • 15