Re: Changing the Text Color of an NSMenuItem in an NSPopUpButton?
Re: Changing the Text Color of an NSMenuItem in an NSPopUpButton?
- Subject: Re: Changing the Text Color of an NSMenuItem in an NSPopUpButton?
- From: Nicholas Riley <email@hidden>
- Date: Fri, 17 May 2002 01:44:55 -0500
- Mail-followup-to: email@hidden
On Thu, May 16, 2002 at 11:07:42PM -0700, mmalcolm crawford wrote:
>
Summary: You can't set the string, but you can set an icon for each
>
item...
Sick. Sick, evil, and oh so effective. Here's a refinement that
makes the popup menu look normal (although obviously there's still a
lot of hard-coding in there, and standard menus don't use the same
font size for the menu as they do for display, for some inexplicable
reason).
NSArray *itemArray = [popup itemArray];
int i;
NSDictionary *attributes = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSColor redColor], NSForegroundColorAttributeName,
[NSFont systemFontOfSize: [NSFont systemFontSize]],
NSFontAttributeName, nil];
for (i = 0; i < [itemArray count]; i++) {
NSMenuItem *item = [itemArray objectAtIndex:i];
NSAttributedString *as =
[[NSAttributedString alloc]
initWithString:[item title]
attributes:attributes];
NSImage *image = [[NSImage alloc] initWithSize: NSMakeSize(90,14)];
[image lockFocus];
[as drawAtPoint:NSMakePoint(2,-2)];
[image unlockFocus];
[item setImage:image];
[item setTitle:@""];
[item setTag:i];
[image release];
}
--
=Nicholas Riley <email@hidden> | <
http://www.uiuc.edu/ph/www/njriley>
Pablo Research Group, Department of Computer Science and
Medical Scholars Program, University of Illinois at Urbana-Champaign
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.