Skip navigation.
 
mlRe: nspopupbuttoncell attribs
FROM : Peter Ammon
DATE : Mon Feb 11 21:08:35 2008

On Feb 10, 2008, at 8:20 PM, William Zumwalt wrote:

> Hi,
>
>
> I've got two questions releated to NSPopUpButtonCell.
>
>
> In my dataCellForRow: method, I'm trying to set the text color but 
> I'm not
> finding a way to do this with an NSPopUpButtonCell like there is for
> NSTextFieldCell which uses setTextColor:. How is this done?


Hi William,

To change the text color of an NSPopUpButtonCell, you should set its 
menuItem attributed title to a colored string.

Of course, this will also change the color of the menu item in the 
menu.  If you want the menu item to draw black but the title to draw 
blue, you should override -[NSPopUpButtonCell drawTitle: withFrame: 
inView:], replace the passed in attributed title to something blue, 
and call super with it.

> Also, in this same method and same control, I'm trying to get rid 
> of the
> checkbox that appears when the popup is enabled in order to match 
> the text
> alignment of the NSPopUpButtonCell with the other NSTextFieldCell's 
> in the
> same column so that they are all left aligned.

...
> The setState: isn't making the checkbox go away which is my 
> understanding of
> what it's for. What am I doing wrong there?


You lost me here....I think you mean checkmark instead of checkbox, 
but even so, the checkmark should not appear in the popup button, 
only in its menu.  Can you provide a screenshot of what you're seeing?

If you want to remove the checkmark space from the menu, you can use -
[menu setShowsMarkColumn:NO], but be aware that the title in the menu 
and in the popup button may no longer line up when the menu is opened.

-Peter

Related mailsAuthorDate
mlnspopupbuttoncell attribs William Zumwalt Feb 11, 05:20
mlRe: nspopupbuttoncell attribs Nick Toumpelis Feb 11, 11:23
mlRe: nspopupbuttoncell attribs Peter Ammon Feb 11, 21:08
mlRe: nspopupbuttoncell attribs Steve Nygard Feb 12, 03:17