Re: NSWindow not restoring location
Re: NSWindow not restoring location
- Subject: Re: NSWindow not restoring location
- From: Edwin Zacharias <email@hidden>
- Date: Thu, 13 Jun 2002 14:24:20 -0400
On Thursday, June 13, 2002, at 03:49 AM, Greg Hulands wrote:
Hi,
I have an inspector that I want to save the location of so that when the
application relaunches it is in the same position. My controller class
for
the inspector is a subclass of NSWindowController.
- (id)init {
self = [self initWithWindowNibName:@"Inspector"];
if (self) {
[self setWindowFrameAutosaveName:@"Inspector"];
needsUpdate = YES;
}
return self;
}
This brings back terrible memories of when I tried to figure this out.
Here you go:
- (id)init {
self = [self initWithWindowNibName:@"Inspector"];
return self;
}
- (void)windowDidLoad
{
[ [ self window ] setFrameAutosaveName: @"Inspector" ];
}
- (void)windowDidMove: (NSNotification *)aNotification
{
[ [ self window ] saveFrameUsingName: @"Inspector" ];
}
Make sure your window controller is the delegate of the window. The
reason for the windowDidMove method is because NSWindow only records its
position when it is resized, not moved.
- Edwin
_______________________________________________
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.