 |
|
 |
 |
 |
 |
|
 |
 |
 |
 |
 |
Edward Hebert, Jr. Guest
 |
Posted: Fri Jul 06, 2007 8:01 pm Post subject: Multiple Views on a Document |
 |
|
I am working on developing a CAD style program. To implement this I am using the Cocoa Document-based Application
I have one main nib and controller for manipulating the objects/data.
I set this with,
- (void)makeWindowControllers
{
NSLog(@"makeWindowControllers");
if(!mainWindowController){
mainWindowController = [[FPMainWindowController alloc] init]; [self addWindowController:mainWindowController]; }
}
where FPMainWindowController is a NSWindowController and the File's Owner of FPMainWindow is set to FPMainWindowController.
Now my questions is if I want to have other views of this scene, that are not open initially, but can be opened by some arbitrary IBAction. Where would I go about initializing and setting these other controllers and nibs? Do I just add them within -(void)makeWindowControllers, similar to my mainWindowController? Having set the controllers and nibs, how do I then link the IBAction top "opening" these windows?
Thank you in advance for the advice. |
|
| |
|
|
|
 |
 |
 |
 |
 |
Michael Ash Guest
 |
Posted: Fri Jul 06, 2007 9:30 pm Post subject: Re: Multiple Views on a Document |
 |
|
Edward Hebert, Jr. <edhebert@sas.upenn.edu> wrote:
| Quote: |
| Now my questions is if I want to have other views of this scene, that are not open initially, but can be opened by some arbitrary IBAction. Where would I go about initializing and setting these other controllers and nibs? Do I just add them within -(void)makeWindowControllers, similar to my mainWindowController? Having set the controllers and nibs, how do I then link the IBAction top "opening" these windows? |
You have two basic choices.
One choice is to add them in makeWindowControllers like you suggest. This won't necessarily display their windows, it just creates the controller. Then in the action, just do [controller showWindow:nil] and you're good.
The other choice is a bit more efficient, and is to load the controller lazily. In this situation you would write the action something like this:
- (IBAction)showFooWindow:(id)sender {
if(!fooController) {
fooController = [[FooWindowController alloc] init]; [self addWindowController:fooController];
}
[fooController showWindow:nil];
}
The efficiency is basically irrelevant though (a window controller doesn't load its nib, which is the really expensive action, until it first shows its window anyway), so pick whichever technique seems best to you. |
|
| |
|
|
|
 |
 |
 |
 |
 |
|
 |
 |
 |
 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|