View Full Version : Launching a custom panel from a menulet

Jul 15, 2012, 04:45 PM
Hi there, moderate newbie here, so please forgive me if I'm missing something basic. I did my best to search for an answer, but couldn't find something that matched what I'm doing.

I'm making a menulet (using this example (http://www.mactech.com/articles/mactech/Vol.22/22.02/Menulet/index.html) as a base), with one of the menu options launching a customized NSPanel. Unfortunately, I just can't get the panel to appear. I've tried two methods:

First, something basic, launched directly from the application controller.

[NSBundle loadNibNamed:@"MyPanel" owner:self];
[myPanel makeKeyAndOrderFront:nil];

This seems to create a ghost menulet with no associated panel or anything else. I've tried subclassing NSPanel and overriding canBecomeKeyWindow to return YES, but that seems to have no effect.

Second, I've tried giving it its own controller class:

- (id)init
self = [super initWithWindowNibName:@"MyPanel"];
return self;

Then launching it by instantiating the class:

if (!myPanelController) {
myPanelController = [[myPanelController alloc] init];
[myPanelController showWindow:self];

This at least doesn't create a ghost menulet, but it doesn't seem to do much else. Any ideas would be greatly appreciated....