Re: Multiple windows B from a window A
Re: Multiple windows B from a window A
- Subject: Re: Multiple windows B from a window A
- From: cogilog <email@hidden>
- Date: Wed, 14 Aug 2002 13:05:57 +0200
le 14/08/02 0:38, email@hidden `
email@hidden a icrit :
>
A question from a beginner.
>
A "New" button in a window A is designed to open a window B.
>
Each hit on this button should open a new window B (as does the command New
>
on a NSDocument based application). The template of window B is designed in
>
IB and is stored in the MainMenu.nib among other window templates.
>
I got a outlet of this template as aWindowB
>
>
I tried this action (connected to the "New" button in window A) :
>
-(IBAction) openWindowB:(id)sender
>
{
>
NSWindowController * aNSWindowController;
>
aNSWindowController=[[NSWindowController alloc] initWithWindow:aWindowB]
>
[aNSWindowController showWindow:aWindowB];
>
}
>
>
the first hit on the button opens a window B as expected but the following
>
hits always open the same window B (not a new one).
>
>
if I create programmatically new instances of window B before creating
>
theNSWindowController, this works (I got different windows B) but in this
>
case I am not able to use the template I have in my nib file for the window
>
B. I am beginner, I should have missed some thing.
>
Thank for your help.
>
>
Jean
I answer to myself.
The only way I have found consists of putting the template of the window B
into a separate nib file "TWindowB.nib", defining a BWindowController class
(which should be the owner of the nib file) and using the following code :
- (IBAction)OpenWindowB:(id)sender
{
BWindowController *aBWindowController;
aBWindowController=[[BWindowController alloc]
initWithWindowNibName:@"TWindowB"];
[aBWindowController showWindow:[aBWindowController window]];
}
Do you think there is still a way to keep the template of the window B in
the MainMenu.nib (to gather with other window templates) ?
The way I found seems rather complicated for a so simple concept.
There is a method to know how many windows are opened in an application
(NSCountWindows) but is there a way to traverse all these windows (for
example to perform closing for some of these) ?
Thank for your help.
Jean
_______________________________________________
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.