Launching a custom panel from a menulet

Discussion in 'Mac Programming' started by CptnJustc, Jul 15, 2012.

  1. CptnJustc, Jul 15, 2012
    Last edited by a moderator: Jul 15, 2012

    CptnJustc macrumors 6502

    Jan 19, 2007
    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 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....

Share This Page