Re:[solved]Statusitems containing items with submenus
Re:[solved]Statusitems containing items with submenus
- Subject: Re:[solved]Statusitems containing items with submenus
- From: Austin Sarner <email@hidden>
- Date: Sat, 15 Jan 2005 16:14:01 -0500
Oops, found my own problem - I was using the same enumerator... hehe.
On Jan 15, 2005, at 3:00 PM, Austin Sarner wrote:
What I am trying to do here is create a statusitem to show a list of folders, each with a submenu of their items. If I remove the submenu creation code for each folder, the list of folders is displayed properly. Otherwise, it only displays a single folder that has a submenu arrow, but no submenu. As you can see enumerate through each folder and each item in the folder constructing an NSMenu. If someone could point me in the right direction, that would be great. Thanks a bunch.
- (void) updateMenu
{
NSMenuItem * folderItem;
NSMenu * itemMenu;
NSMenuItem * snippetItem;
NSEnumerator *enumerator = [[statusMenu itemArray] objectEnumerator];
NSEnumerator *itemEnumerator;
SnippetFolder *folder;
SnippetItem *theItem;
while(folderItem=[enumerator nextObject])
if([folderItem action]==@selector(switchGeneral:))
[statusMenu removeItem:folderItem];
enumerator=[_folders reverseObjectEnumerator];
while ((folder = [enumerator nextObject]))
{
folderItem = [[NSMenuItem alloc] initWithTitle:
[[[[folder properties] objectForKey:@"title"] componentsSeparatedByString:@"***"]
objectAtIndex:0] action:@selector(switchGeneral:) keyEquivalent:@""];
//create item menu
itemMenu = [[NSMenu alloc]init];
enumerator=[[folder items] reverseObjectEnumerator];
while ((theItem = [enumerator nextObject]))
{
[itemMenu addItem:[[NSMenuItem alloc] initWithTitle:[[[[theItem properties]
objectForKey:@"text"] componentsSeparatedByString:@"***"]
objectAtIndex:0] action:@selector(pasteSel:) keyEquivalent:@""]];
}
[folderItem setImage:[NSImage imageNamed:@"folder"]];
[folderItem setTarget:self];
[folderItem setSubmenu:itemMenu];
[statusMenu insertItem:folderItem atIndex:0];
}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden