Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

please help: menu items with attributed strings are appearing blank



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: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.