NSUIElement

  • I'm using the new XCode and trying to build an NSUIElement. In the
    info plist I've added the line to do that. NSUIELement 1. In the IB I
    created a menu with 1 item in it. It is connected to the controller as
    uiMenu. However when I launch the application no icon shows in the
    dock and no menu ever appears in the status menu. below is the code
    used to set up the menu: What's most frustrating is that this code is
    cut from another application of mine that does work it just doesn't
    work in the new app. So either I';m missing something or I am not
    connecting something correctly in IB

    -(void)setupIcon
    {

    NSImage * icon = [NSImage imageNamed:@"bsf.icns"];
        [icon setScalesWhenResized:YES];
        NSSize size = NSMakeSize(16.0,16.0);
        [icon setSize:size];
        menuItem = [bar statusItemWithLength:18.0];
        [menuItem retain];
        [menuItem setImage:icon];
        [menuItem setHighlightMode:YES];
    [menuItem setMenu:uiMenu];
    }

    -(void)awakeFromNib
    {
    NSLog(@"Awake from nib");


    [self setupIcon];

    }
  • Someone wrote:

    > I'm using the new XCode and trying to build an NSUIElement. In the
    > info plist I've added the line to do that. NSUIELement 1. In the IB I
    > created a menu with 1 item in it. It is connected to the controller as
    > uiMenu. However when I launch the application no icon shows in the
    > dock

    That'd be because you made it a UI element.

    > and no menu ever appears in the status menu. below is the code
    > used to set up the menu: What's most frustrating is that this code is
    > cut from another application of mine that does work it just doesn't
    > work in the new app. So either I';m missing something or I am not
    > connecting something correctly in IB
    >
    > -(void)setupIcon
    > {
    > NSImage * icon = [NSImage imageNamed:@"bsf.icns"];
    > [icon setScalesWhenResized:YES];
    > NSSize size = NSMakeSize(16.0,16.0);
    > [icon setSize:size];
    > menuItem = [bar statusItemWithLength:18.0];
    > [menuItem retain];
    > [menuItem setImage:icon];
    > [menuItem setHighlightMode:YES];
    > [menuItem setMenu:uiMenu];
    > }
    >
    > -(void)awakeFromNib
    > {
    > NSLog(@"Awake from nib");
    > [self setupIcon];
    > }

    What's "bar?" Not "what's bar supposed to be?" but "what, actually,
    is it?" I don't see any indication that it's been set to anything
    before it gets used.
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today