KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've got a statusbar item that pops open an NSMenu, and I have a delegate set and it's hooked up correctly ( -(void)menuNeedsUpdate:(NSMenu *)menu works fine). That said, that method is setup to be called before the menu is displayed, I need to listen for that and trigger an asynchronous request, later updating the menu while it is open, and I can't figure out how that's supposed to be done. Thanks :) EDIT Ok, I'm now here: When you click on the menu item (in the status bar), a selector is called that runs an NSTask. I use the notification center to listen for when that task is finished, and write: [[NSRunLoop currentRunLoop] performSelector:@selector(updateTheMenu:) target:self argument:statusBarMenu order:0 modes:[NSArray arrayWithObject:NSEventTrackingRunLoopMode]]; and have: - (void)updateTheMenu:(NSMenu*)menu { NSMenuItem *mitm = [[NSMenuItem alloc] init]; [mitm setEnabled:NO]; [mitm setTitle:@"Bananas"]; [mitm setIndentationLevel:2]; [menu insertItem:mitm atIndex:2]; [mitm release]; } This method is definitely called because if I click out of the menu and immediately back onto it, I get an updated menu with this information in it. The problem is that it's not updating -while the menu is open-.
Tags (comma-separated)
Save Edits
Cancel