# Making a sheet from a subclass of NSWindow



## redbird (Dec 23, 2002)

Does anyone know of a way to have a subclass of NSWindow appear as a sheet?  It seems to me like it should just work, but it refuses to display as a sheet.

Alternatively, might it be something related to that I'm trying to make it relative to an NSWindow that belongs to an NSDocument subclass?


----------



## anarchie (Dec 23, 2002)

Try making a NSPanel subclass.  NSPanel is an NSWindow subclass adapted for sheets and utility windows.


----------



## redbird (Dec 23, 2002)

> _Originally posted by anarchie _
> *Try making a NSPanel subclass.  NSPanel is an NSWindow subclass adapted for sheets and utility windows. *



Actually, I started out with subclasses of NSPanel, but they wouldn't work either.  I move to subclasses of NSWindow because I remember a while back I found that I could only make sheets from an NSWindow.  If I changed the window to an NSPanel (say, in IB) then it would refuse to run as a sheet (or, rather, it would run like a sheet, but would not visually attach itself to a window).


----------



## anarchie (Dec 23, 2002)

What code are you using to bring up the sheet?  If you are using IBOutlets, have you made sure to use them only during or after -awakeFromNib is called?


----------



## redbird (Dec 23, 2002)

> _Originally posted by anarchie _
> *What code are you using to bring up the sheet?  If you are using IBOutlets, have you made sure to use them only during or after -awakeFromNib is called? *



//GPGPassphrasePanel is a subclass of NSWindow

GPGPassphrasePanel *ppanel = [GPGPassphrasePanel panel];

//do some stuff to set up ppanel

    [NSApp beginSheetpanel
       modalForWindow:window
        modalDelegate:nil
       didEndSelector:nil
          contextInfo:nil];

All of those nils will eventually be replaced, but this is just a test right now.  This is from a method inside an NSDocument subclass and window is the document's NSWindow.  This function is called as a result of a user clicking a button long after awakeFromNib was called.

One possibility, though, is that GPGPassphrasePanel might not have been awaken (it uses IB files, too).  Is this even possible, though?


----------



## anarchie (Dec 23, 2002)

Try instantiating your GPGPassphrasePanel in your document's nib.  Perhaps there's something awry with creating it programatically.  Do you mean to say that in your panel's init method or whatnot, it attempts to load a nib of its own?


----------

