Re: [newbie] Handling a preferences window
Re: [newbie] Handling a preferences window
- Subject: Re: [newbie] Handling a preferences window
- From: James DiPalma <email@hidden>
- Date: Tue, 1 Oct 2002 11:47:57 -0400
I continue to respond in this thread because you have a good solution
(arguably better for newbies) for bringing up a preferences panel and I
want your solution to part of this list's archives, but I keep getting
it wrong (maybe if I were a newbie, I would get it right and these last
few posts are really just for my own benefit).
From: Jeremy Dronfield <email@hidden>
From: James DiPalma <email@hidden>
I think I now understand what you are suggesting:
1. Make a subclass of NSWindowController and instantiate it in
MainMenu.nib
2. Connect your preferences menu item to showWindow:
3. In NSWindowController's init method call initWithWindowNibName:
4. In NSWindowController's init method call
setWindowFrameAutosaveName:
I like this suggestion. It may or may not be how you would implement
it, but it accurately takes your suggestions and preferences for
NSWindowController and shows how to implement a solution to this
post's original question.
Closer, but still no cigar. What you've actually done here is conflate
a selection of suggested solutions for different situations into one
design. For the full selection, I refer you back to the last-but-one
paragraph of my last post.
Your last-but-one paragraph of your last post is included in bits below:
What I *did* suggest to the original poster was that they should:
1. Use -showWindow: if the window had a controller in MainMenu.nib;
My no-cigar solution uses a window controller in MainMenu.nib and uses
showWindow: to bring up a preferences panel.
2. Use -makeKeyAndOrderFront: if the window was in MainMenu.nib but
had no controller;
Not relevant because my no-cigar solution puts this window in a
separate nib.
3. Ideally put their prefs window in a separate nib.
I didn't actually state that this window goes into its own nib file,
but only because I was being careless/incomplete. By calling
initWithWindowNibName: in my no-cigar window controller's init method,
I meant to suggest that this nib name would be something like
Preferences.nib (if I wanted to suggest that this window be in
MainMenu.nib, I would not be able to use initWithWindowNibName:).
4. Read some documentation.
You copy in some documentation in your last mail which highlights 2
points: that when using multiple nib files a window controller can be
used to load a nib file, and that NSWindowControllers are usually the
owner of a nib file.
My no-cigar solution uses an NSWindowController subclass to open a
second nib for this preferences panel and sets this window controller
as this nib's file's owner: -initWithWindowNibName: calls
initWithWindowNibName:owner: using self as owner.
5. Er, that's all.
I don't know what may still be different from my no-cigar solution and
what you do in your own apps. I hope this post is a reasonable
explanation of both your solution and how your suggestions can be
developed into a solution.
-jim
P.S. I will still continue to use an NSObject subclass as my
preferences controller and avoid using an NSWindowController. I do this
not because I think everyone should do so, but because: I feel
uncomfortable with my preference controller having window controller
responsibilities, and I personally get confused by NSWindowController's
full set of responsibilities. Some people might understand these
feelings and also be uncomfortable, but I did not intend to imply that
NSWindowController should not be used in a way consistent with its
design and documentation.
_______________________________________________
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.