Re: [Newbie] How to load and display a sheet from a NIB file ?
Re: [Newbie] How to load and display a sheet from a NIB file ?
- Subject: Re: [Newbie] How to load and display a sheet from a NIB file ?
- From: Jérome Foucher <email@hidden>
- Date: Thu, 20 Mar 2003 13:53:53 +0100
On jeudi, mars 20, 2003, at 12:29 Europe/Paris, Nick Zitzmann wrote:
On Thursday, March 20, 2003, at 02:43 AM, Jirome Foucher wrote:
This NIB file holds the window and 2 sheets.
I want to display the first sheet when the user click the "Add"
button, and the second one when he/she clicks on the "Delete" button.
From my understanding, I should use the beginSheet method from
NSApplication.
But I don't really understand how I should load the sheet from the
NIB file....
Do I have to put each sheet into a separate NIB file ?
No, not unless you want to, anyway.
Do I need to create a custom class for each sheet too ?
No. What you do is this: (std. disclaimer: code typed in Mail,
untested, use at your own risk, etc.)
1. Create two new panels ("NSPanel" class) in some nib loaded by your
application, one for your Add button and one for your Delete button.
2. Make an outlet for each panel from the class you want to control
them.
3. Use something like this for your Add button action:
- (IBAction)addButtonClicked:(id)sender
{
[NSApp beginSheet:ADD_SHEET modalForWindow:PARENT_WINDOW
modalDelegate:self
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}
Replace ADD_SHEET with the outlet name of the Add panel
That was the part I was missing.
I was thinking too complex, and Cocoa is so simple. Damned !!!
I definitely love Cocoa.
Thanks
Jerome
_______________________________________________
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.