please help: menu items with attributed strings are appearing blank
please help: menu items with attributed strings are appearing blank
- Subject: please help: menu items with attributed strings are appearing blank
- From: mercer <email@hidden>
- Date: Tue, 7 Nov 2006 11:13:49 -0500
Hi. I'm writing an NSStatusItem that displays a menu when clicked. In
that menu, I'm trying to make all of the menu items appear in 9 point
Monaco instead of the usual Lucida Grande font.
I can't get it to work. When it runs, I get a blank menu. When I skip
the line where I'm trying to use an attributed string, it works,
except that the menu items appear in the regular system font, and
that's not what I want.
I appreciate any help you can offer. Thanks.
-m
Below is a code snippet.
//here is an attributed string just for testing
NSMutableAttributedString *attString = [[NSMutableAttributedString
alloc] initWithString:@"Testing 123"];
//make the attributed string monaco 9
[attString addAttribute:NSFontAttributeName
value:[NSFont fontWithName:@"Monaco" size:9]
range:NSMakeRange(0,[attString length])];
//create menu item
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:@"Testing
123" action:nil keyEquivalent:@""];
//push the attributed string into the menu item
//NOTE: WITHOUT THIS LINE, THE MENU ITEM APPEARS, BUT IN THE SYSTEM FONT
[menuItem setAttributedTitle:attString];
//add this menu item to the menu
[menu addItem:menuItem];
//tell the NSStatusItem to use this menu the next time someone clicks
on the icon
[statusItem setMenu:menu];
_______________________________________________
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