FROM : Gregory Weston
DATE : Fri Nov 26 22:50:28 2004
On Nov 26, 2004, at 3:27 PM, John Spicer wrote:
> Is it possible to do this? I have a window (prefs) in one place that
> uses it as the content (using setContentView or something like it),
> and in another place I need it to come down from the login window as a
> sheet.
> Is there a way to do this? Otherwise it looks like two nibs and I
> guess two copies of the code (which I don't like).
> Advice, anyone?
Doesn't take two nibs. Just one that's loaded two times. This is
probably not the most elegant technique, but it works....
+ (void)displayModalForWindow:(NSWindow*)inWindow
{
static MyController* sPanel = NULL;
static MyController* sSheet = NULL;
if(inWindow)
{
if(!sSheet) sSheet = [[MyController alloc]
initWithWindowNibName:@"MyNibFile"];
[NSApp beginSheet:[sSheet window] modalForWindow:inWindow
modalDelegate:sSheet
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
}
else
{
if(!sPanel) sPanel = [[MyController alloc]
initWithWindowNibName:@"MyNibFile"];
[sPanel showWindow:self];
}
}
This is heavily trimmed but I don't think I broke it in the process.
DATE : Fri Nov 26 22:50:28 2004
On Nov 26, 2004, at 3:27 PM, John Spicer wrote:
> Is it possible to do this? I have a window (prefs) in one place that
> uses it as the content (using setContentView or something like it),
> and in another place I need it to come down from the login window as a
> sheet.
> Is there a way to do this? Otherwise it looks like two nibs and I
> guess two copies of the code (which I don't like).
> Advice, anyone?
Doesn't take two nibs. Just one that's loaded two times. This is
probably not the most elegant technique, but it works....
+ (void)displayModalForWindow:(NSWindow*)inWindow
{
static MyController* sPanel = NULL;
static MyController* sSheet = NULL;
if(inWindow)
{
if(!sSheet) sSheet = [[MyController alloc]
initWithWindowNibName:@"MyNibFile"];
[NSApp beginSheet:[sSheet window] modalForWindow:inWindow
modalDelegate:sSheet
didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:)
contextInfo:NULL];
}
else
{
if(!sPanel) sPanel = [[MyController alloc]
initWithWindowNibName:@"MyNibFile"];
[sPanel showWindow:self];
}
}
This is heavily trimmed but I don't think I broke it in the process.
| Related mails | Author | Date |
|---|---|---|
| John Spicer | Nov 26, 15:36 | |
| John Spicer | Nov 26, 20:00 | |
| Eric Forget | Nov 26, 20:22 | |
| Gregory Weston | Nov 26, 22:50 |






Cocoa mail archive

