Instantiate a drawer by itself?

So I was reading in the documentation that:
“It is also possible to instantiate a drawer by itself (without a parent window or content view) by dragging the object labeled “Drawer” in Interface Builder’s Cocoa-Windows palette to a nib window. In that case, you will get just the NSDrawer instance, and you will have to hook it up to a window and content view yourself (the details of which are beyond the scope of this reference).”

However, I have not found any other reference on how to do this either. I would really like to break all my windows, draws, and panels into their own nib and script files, however I am having a hard time attaching the drawer to a window of another nib file.

Any tips? or know of any documentation/examples on how to do this?

Thanks a bunch!

  • Brett

If you drag a window with a drawer to a nib file you will see that there are 3 components to that combination. You get a window, a drawer, and a contentView. If you look in the connections section of the inspector you will see that it is the drawer that makes the connections to 1) the parent window and 2) the content view.

So all you need to do is break those connections to unhook the drawer from the other 2. Once the connections are broken you can delete the un-used stuff from your nib. Then in your code you can programatically set the parent window and content view of the drawer to whatever you want. I explained it using the full window/drawer/content view combination so you can see what the full package needs to look like and what you need to do in order to get a functioning drawer again.

set content view of myDrawer to whatever
set parent window of myDrawer to whatever