Re: Dynamically loading NIB files into sheets
Re: Dynamically loading NIB files into sheets
- Subject: Re: Dynamically loading NIB files into sheets
- From: j o a r <email@hidden>
- Date: Sun, 14 Apr 2002 01:22:19 +0200
On Saturday, April 13, 2002, at 11:22 , Sebastian Celis wrote:
I've thought about creating a SheetController class that each Document
has an instance of, and then having this SheetController class have
instances of SheetControllerA, SheetControllerB, and so on for the
number of sheets I have... but I'm having trouble implementing it
(specifically with regard to what class calls what method and what the
syntax of the final method to display the sheet should be).
The SheetController could be a subclass of NSObject, responsible for
instantiating SheetWindowControllers matching the provided sheetID's,
and keeping track of them - once loaded, they should be kept around to
be able to be re-used.
What about having a method in your SheetController called:
- (SheetWindowController *) sheetControllerForIdentifier:(NSString
*)sheetIdentifier;
The SheetWindowController could be a subclass to NSWindowController,
with just the methods added for it to be the delegate of the sheet,
et.c. as outlined above.
Then you add a method in your document to associate a pop up menu item
with a sheet identifier:
- (NSString *) sheetIdentifierForTag:(int)tag;
Assuming that you have the following outlets in your document:
NSWindow * myDocumentWindow;
NSPopUpButton * myPopUpButton;
SheetController * mySheetController;
The sheet is then opened when the button is pushed by calling something
like this:
- (IBAction) openSheet:(id)sender
{
NSString *sheetID = [self sheetIdentifierForTag:[[myPopUpButton
selectedItem] tag]];
SheetWindowController *sheetCtrl = [mySheetController
sheetControllerForIdentifier:sheetID];
[NSApp beginSheet:[sheetCtrl window]
modalForWindow:myDocumentWindow modalDelegate: sheetCtrl
didEndSelector:[sheetCtrl selector] contextInfo:nil];
}
What do you think? I'm not sure you need an extra layer of objects using
the SheetWindowControllers - you could also just put the appropriate
outlets in the SheetController and then use [NSBundle loadNibNamed:@""]
and load the sheets there - but it's up to you.
j o a r
_______________________________________________
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.