Re: Newbie needs pointers on customizing New behaviour
Re: Newbie needs pointers on customizing New behaviour
- Subject: Re: Newbie needs pointers on customizing New behaviour
- From: Serge Meynard <email@hidden>
- Date: Tue, 05 Apr 2005 20:28:08 -0400
On Apr 5, 2005, at 14:01, Huibert Aalbers wrote:
This is probably a very simple question but I have not been able to
find any samples or tutorials explaining how to customize a document
based application so that I can display a panel with a couple of
configuration parameters before actually creating the New document.
Any help/pointers would be greatly appreciated.
Regards,
Huibert
I do the same thing in my app, so I had to figure it out myself. Here's
how I handle it... In your app delegate class, add these methods:
- (IBAction) askCreateNewFile:(id)sender
{
if ([self shouldOpenNewDocument] == YES)
[NSApp sendAction:@selector(newDocument:) to:nil from:sender];
}
- (BOOL) shouldOpenNewDocument
{
newDocumentController = [self newDocumentController];
NSWindow* dialogWindow = [newDocumentController window]; [dialogWindow
center];
[dialogWindow makeKeyAndOrderFront:self];
int resultCode = [NSApp runModalForWindow:dialogWindow];
[newDocumentController close];
return (resultCode == NSRunStoppedResponse) ? YES : NO;
}
- (YourNewDocController*) newDocumentController
{
if (newDocumentController == nil)
newDocumentController = [[YourNewDocController alloc]
initWithWindowNibName:@"YourNewDocNibFile"];
return newDocumentController;
}
Add the shared controller member variable to the class. Then in your
MainMenu.nib, redirect the "New..." menu item to "askCreateNewFile:",
and you're done.
Hope this helps...
Serge
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden