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: Richard Kendall Wolf <email@hidden>
- Date: Thu, 16 May 2002 17:40:23 -0500
On Thursday, May 16, 2002, at 04:37 PM, email@hidden wrote:
Richard Kendall Wolf wrote:
Take pity on a newbie! I promise I checked the archives first. Feel
free to flame if I overlooked the answer in the archives.
Relax! Not everyone on this list is gunning down the newbies. And, if
you keep score, you'll soon discover who does and who doesn't, and you
can then ignore the ones who do.
I have just enough self-esteem and respect for list culture not to want
to ruffle any feathers, so I'll always try to do my homework first. :-)
I think I have a legitimate reason to want to set the color of text in
an NSMenuItem within an NSPopUpButton. Just so the user interface guys
don't freak, I don't want to allow the user to be able to change the
color ... and I want to restrict the text color to just two colors:
red
and black.
All the methods that set/return text in a popup button do so with
NSStrings. What I think I'm after is the NSText, for which I can set
the color easily (just like I could, say, for an NSTextField).
I'm assuming you already know how to track down the appropriate
NSMenuItem.
Oh yeah, I worked that out. :-) In the past two days I've learned a
ton about NSMenus, NSMenuItems, and NSPopUpButtons.
This is pure guesswork, but what happens if you set the item title to
an NSAttributedString? You can set the foreground and background colors
of one, and that might give you what you need.
I'll give that a whirl! Thanks for the tip.
As a UI note: the colors you name suggest that you're intending to use
the color as an indicator of some sort (an error indicator, I'd guess,
that being what red is often used for).
Actually, I have another use in mind. :-) What I am after is an
application that is simple in conception, but that will help me learn
Cocoa. Borrowing from the "Currency Converter" paradigm, I created a
"Duplicate Bridge Scorer" application. Basically, duplicate bridge is a
version of the game of bridge that is played competitively in clubs, and
from which "luck" has been effectively removed (even though it is played
with cards, it is a pure game of skill). The game, it turns out, has a
moderately complex scoring system and I thought it would be fun to wrap
a model object around it, a la Currency Converter. So I spent a couple
of hours coding the rules and everything works just great. When I was
working on the user interface for the app, I created an NSPopUpBotton to
represent the suit for any given contract. At first I used the words,
"Clubs," "Diamonds," "Hearts," "Spades," and "Notrump" in the popup's
menu items, but then I thought better of it, and decided to go with the
suit symbols ... so I coded those as UTF8 characters (thank you
unicode.org!) and worked out how to deal with them. Then it occurred to
me that hearts and diamonds aught to be a dark red color. In my
opinion, this will make the popup easier to use because everyone
"expects" a heart to be red on a playing card. Wouldn't this be
considered a legitimate reason for straying from the standard menu item
text color?
If so, keep in mind that not everyone can tell red from black (totally
colorblind people will just see shades of grey, which are much less
distinctive), so there should be something besides color that would
also indicate whatever you'd be indicating.
I actually considered this possibility. I am not sure, but I thought
that using a darker red color would work. Confessing ignorance and
meaning no disrespect to those on the list who have difficulty
distinguishing color, would this be a reasonable compromise (using a
-dark- red color, that is)? I am actually kind of curious about this
because, during my consideration of it, I recalled that Apple's own
currency NSFormatter allows negative amounts to be shown in red.
_______________________________________________
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.