How to make a NSPanel show up in Windows menu?
How to make a NSPanel show up in Windows menu?
- Subject: How to make a NSPanel show up in Windows menu?
- From: Dustin Voss <email@hidden>
- Date: Sat, 17 Aug 2002 05:56:41 -0700
Pretty much like the subject says. I've got an NSPanel (a Find panel), and
I'd like it, and most other modeless panel I'm anticipating, to show up in
the Windows menu.
NSPanel inherits from NSWindow, of course, and NSWindow has that
isExcludedFromWindowsMenu: method. NSPanel sets this to YES. This isn't
documented, by the way, I've noticed that the docs don't describe
overrides. But that's a gripe for another day.
So in my FindController class's init method, I load the panel from a NIB
and call setExcludedFromWindowsMenu:NO on the panel. But that doesn't seem
to have an effect; the panel still doesn't show up in the Windows menu
when I display it later (with makeKeyAndOrderFront:). I also tried doing
the same thing in an awakeFromNib method, with similar (i.e. no) effect.
So, what do I have to do to put the panel in the Window menu?
I've searched my list archive, and couldn't find anything. I'm surprised
it hasn't come up before. Here's the relevant parts of my controller (I
inherit from NSObject, not NSWindowController):
@interface FindController : NSObject
{
IBOutlet NSPanel *thePanel;
}
- (id) init
{
[super init];
if (![NSBundle loadNibNamed:@"FindDialog" owner:self])
{
NSLog (@"Could not load FindDialog.");
[self release]; // I think this is a little sloppy, but I'm not sure.
return nil;
}
return self;
}
- (void) awakeFromNib
{
if ([[self superclass]
instancesRespondToSelector:@selector(awakeFromNib)])
[super awakeFromNib]; // This if statement isn't really needed.
[thePanel setExcludedFromWindowsMenu:NO];
[[NSApp mainMenu] update]; // This probably isn't needed, either.
}
- (void) showWindow:(id)sender
{
[thePanel makeKeyAndOrderFront:sender];
}
--
Dustin
_______________________________________________
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.