Re: Use Window Frame Autosave, or fall back to Cascade
Re: Use Window Frame Autosave, or fall back to Cascade
- Subject: Re: Use Window Frame Autosave, or fall back to Cascade
- From: Jerry Krinock <email@hidden>
- Date: Tue, 19 Jun 2007 22:16:07 -0700
On 2007 Jun, 19, at 19:57, Seth Willits wrote:
It's pretty simple to do this. I do it by:
Ah, yes. Now I see that there is a Stupid Way and a Smart Way to do
this. You're saying that instead of, as I had mused, changing the
default -setShouldCascadeWindows:NO to let Cocoa implement the easy
branch (frameAutosave) and then writing code to implement the
difficult branch (cascading), I should instead leave the default -
setShouldCascadeWindows:YES to let Cocoa implement the difficult
branch (cascading) and write code to implement the easy branch
(frameAutosave).
Thanks, Seth, that's a damned good idea! Actually, because -
setFrameUsingName returns whether or not it is successful, it's even
easier than you thought.
So, for the record, here it is, in my window controller subclass. -
frameAutosaveName is a getter for an instance variable which is set
in the -init... method.
- (void)awakeFromNib {
[[self window] setFrameAutosaveName:[self frameAutosaveName]] ;
[[self window] setDelegate:self] ;
...
}
// Delegate Methods...
- (void)windowDidLoad {
BOOL usedAutosave = [[self window] setFrameUsingName:[self
frameAutosaveName]] ;
[self setShouldCascadeWindows:!usedAutosave] ;
}
Kind of weird that -setShouldCascadeWindows:NO seems to enable
setFrameUsingName retroactively, after it has already executed and
presumably failed due to the default setting of YES. But that's
exactly the way it seems to work!
Maybe time for a documentation bug, because "To ^preclude^ the window
controller from changing a window’s position from the one saved in
the defaults system, you must send setShouldCascadeWindows:NO to the
window controller" does indeed imply doing it the Stupid Way.
Thanks again,
Jerry
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden