On Jul 5, 2008, at 3:53 PM, Chris Hanson wrote:


On Jul 5, 2008, at 8:30 AM, John Joyce wrote:

In my application, I would like to give my users the option to choose various interface styles. I've laid out my interface using a standard NSPanel as well as the HUD version. Both are suitable, but some users will prefer one over the other, of course.
Currently, I have both windows in one NIB.
Is there a way to choose which window is loaded from the NIB?
Is it possible to do this without losing the data in the document? (it is document based) Would it be better/more practical to factor these into two different NIBs?

Yes. Refactor your interface into two nibs, where each nib is owned by an NSWindowController rather than by an NSDocument subclass. Then you can override -[NSDocument makeWindowControllers] in your NSDocument subclass to instantiate whichever NSWindowController is initially appropriate, and when you want to "switch" interface styles you can use -[NSDocument addWindowController:] and - [NSDocument removeWindowController:] to get rid of the old and add the new.

 -- Chris

Thanks Chris, this leads me pretty much where I suspected I would end up going. One other thing, does this mean I need to subclass NSWindowController as well? Or simply create instances of the default NSWindowController and feed them as necessary?

Either way, from my NSDocument subclass (MyDocument as usual) I should be able to instantiate more than one window controller, and then load my respective NIBs by [NSDocument addWindowController:aWindowController]
Will adding a window controller release / close the current window?

Clearly, I'm heading down the path of becoming more acquainted with NSWindowController, which seems inevitable if one wishes to do interesting things with the interface. I figured as much. Perhaps this means I'm beginning to grasp more of the AppKit.

It does look like it will take a little experimentation to get precisely what I want, but that's cool, it means I will be more aware of how to do interesting things!

-- John Joyce
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please 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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to