• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem


  • Subject: Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem
  • From: "Mark D. Gerl" <email@hidden>
  • Date: Tue, 3 Mar 2009 14:30:57 -0500

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:email@hidden>

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem (SOLVED)
      • From: "Mark D. Gerl" <email@hidden>
    • Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem
      • From: Andy Lee <email@hidden>
    • Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem
      • From: "Mark D. Gerl" <email@hidden>
    • Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem
      • From: Nick Zitzmann <email@hidden>
References: 
 >Can't get setDelegate to work on NSMenu attached to NSStatusItem (From: "Mark D. Gerl" <email@hidden>)
 >Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: NSDocumentController Problem
  • Next by Date: Re: fieldEditor not scrolling to keep insertion point / indicator visible
  • Previous by thread: Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem
  • Next by thread: Re: Can't get setDelegate to work on NSMenu attached to NSStatusItem
  • Index(es):
    • Date
    • Thread