• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Newbie needs pointers on customizing New behaviour
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Newbie needs pointers on customizing New behaviour (From: Huibert Aalbers <email@hidden>)

  • Prev by Date: Re: ADC Core Data article
  • Next by Date: Re: ADC Core Data article
  • Previous by thread: Newbie needs pointers on customizing New behaviour
  • Next by thread: weird problem with IB
  • Index(es):
    • Date
    • Thread