Re: NSWindow not restoring location
Re: NSWindow not restoring location
- Subject: Re: NSWindow not restoring location
- From: Brock Brandenberg <email@hidden>
- Date: Thu, 11 Jul 2002 03:42:25 -0500
While this is an old thread topic, I just discovered a solution to this
problem and wanted to add it to the archives. The problem exists when trying
to restore the exact position of singleton windows and panels like inspector
palettes. I searched the archives to try and connect the problem and
solution, but couldn't find a mention of them together (much less any
confirmed solution to this problem).
When trying to restore the location of a window from the default plist using
[window setFrameUsingName:], sometimes your window location will be restored
properly and sometimes it will not. This is because the window controller
wants to insure that a window lies completely within the [NSScreen
visibleFrame], and it will do whatever is necessary to make this happen when
it's given the responsibility of positioning the window. Herein lies the
key. When you call setFrameUsingName: with a valid saved frame (one that is
completely within the visibleFrame) your window may be still be moved
because the windowController may be cascading your window for you. When this
happens, the windowController is taking on the responsibility of finding a
new valid location for the window. If the cascaded position does not lie
within the visibleFrame, the controller will find a new location for the
window, typically somewhere in the top left of the visibleFrame.
So, the solution is to call [NSWindowController setShouldCascadeWindows:NO]
in your NSWindowController subclass to turn this behavior off for the
controller of any singleton window you are trying to position. After that,
it should explicitly restore the position no matter where it was previously
located. Just make sure to set your autosave name properly and call [window
setFrameUsingName:] in [NSWindowController windowDidLoad].
Brock Brandenberg
----- industrial design @ www.bergdesign.com ------
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.