FROM : Serge Meynard
DATE : Wed Apr 06 02:28:08 2005
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
DATE : Wed Apr 06 02:28:08 2005
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
| Related mails | Author | Date |
|---|---|---|
| Huibert Aalbers | Apr 5, 20:01 | |
| Serge Meynard | Apr 6, 02:28 |






Cocoa mail archive

