Cocoa Sheets How To
Sheets, of course, being those windows that drop down from the top of, and are attached to, another window. It’s pretty simple, but I had a hard time finding any documentation or Google info about it. So here is what I finally found/figured out:
1. First create the windows or panels in Interface Builder that will be the sheet and the window/panel that the sheet is attached to. If your sheet is a panel, set the style to “Document Modal”.
2. Then do this in obj-c:
[NSApp beginSheet:mySheet modalForWindow:myPanel
modalDelegate:self didEndSelector:NULL contextInfo:nil];
.
.
.
[NSApp endSheet:mySheet];
[mySheet orderOut:self];
[mySheet performClose:self];
I’m not sure if that last performClose statement is needed, but it can’t hurt.
September 23rd, 2008 at 5:14 pm
where are mySheet and myPanel defined? are they NSWindow instances?
September 23rd, 2008 at 5:21 pm
You create the mySheet and myPanel in Interface Builder and then hook them to IBOutlets in your code. They are both NSPanel or NSWindow instances. It’s up to you.