On Mar 3, 2009, at 11:52 AM, Nick Zitzmann wrote:

Can you please show your code? I've done this before, and it worked when I tried it.

SURE, see below. I should point out that I've also tried implementing other delegate methods, with no luck. And, I've tried setting the menu's delegate AFTER setting the menu for the NSStatusItem - with the same results.



@interface SampleController : NSObject {
        // nothing here
}
-(void)menuHandler:(id)sender;
- (void)menuNeedsUpdate:(NSMenu *)menu;
@end

@implementation SampleController

-(void)menuHandler:(id)sender
{
        // works fine
}

-(void)menuNeedsUpdate:(NSMenu *)menu   // delegate method
{
        // *** NEVER GETS HERE ****
}
@end


// put this wherever...

NSStatusItem statusItem=[[[NSStatusBar systemStatusBar]
        statusItemWithLength:NSVariableStatusItemLength] retain];
        
[statusItem setHighlightMode:YES];
[statusItem setTitle:@"XYZ"];
[statusItem setMenu:theMenu];
[statusItem setEnabled:YES];

// build NSMenu by HAND
NSMenu *menu = [[[NSMenu alloc] initWithTitle:@"abc"] autorelease];
if (menu != NULL)
{
        SampleController *menuController =
                [[[SampleController alloc] init] autorelease];
                                        
        [menu setAutoenablesItems:NO];
                                        
        NSMenuItem *item = [menu addItemWithTitle:@"Quit"
action:@selector(menuHandler:) keyEquivalent:@""]; [item setTarget:menuController];
        [item setTag:9];
        [item autorelease];
                                        
        // *** DOING this causes the menu to NOT pop down ***
        [menu setDeligate:menuController];
                                        
        [statusItem setMenu:menu];
}

Thanks,
M

--
Mark D. Gerl, Multimedia Design Group, <mailto:mg...@mmdesigngrp.com>

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to