• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Conditionally formatting cells in an NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Conditionally formatting cells in an NSTableView


  • Subject: Re: Conditionally formatting cells in an NSTableView
  • From: Julian Barkway <email@hidden>
  • Date: Tue, 26 Nov 2002 20:43:43 +0100

On Tuesday, November 26, 2002, at 03:56 pm, Tamara L. Cravit wrote:

> What I'd like to do next is to conditionally format some cells to be in
> bold, based on whether or not a particular data element is nil. Can I
> do
> this in the NSTableDataSource "aTable objectValueForTableColumn:row:"
> method, or is there somewhere better to do this?

Short answer: Yes.

Since you don't actually have access to your table's NSCell at this
point, there is nothing useful that you can format. Instead, you need
to implement the delegate method
tableView:willDisplayCell:forTableColumn:row: in your table view's
delegate as this handily supplies you with an NSCell (by default an
NSTextFieldCell) to which formatting messages can be sent. Bear in mind
that the same cell is reused for each row and column combo that is
displayed so you will need to set or reset your attributes accordingly
each time your method is invoked. To get boldface, you will need to
first convert your font using the FontManager and then pass it to the
cell's setFont: method.

Which brings me to my number one Cocoa peeve. Unfortunately, unlike
OS9, 'bold' is no longer an attribute that can be applied to a font.
This means that if the font family you are using doesn't have a bold
variant you won't get boldface. NSFontManager's
convertFont:toHaveTrait: sounds like it will do this but all it does,
in effect, is to look for a boldface variant of the supplied font and
if it doesn't find one, it gives up. It would be nice if there was at
least the option of returning a faked bold or italic face...

--
Julian Barkway,
Zurich,
Switzerland.
_______________________________________________
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.

  • Prev by Date: Re: Vermont Recipes vs Building Cocoa Applications
  • Next by Date: Re: How to know if the System Preferences app is running
  • Previous by thread: Re: Conditionally formatting cells in an NSTableView
  • Next by thread: Re: Conditionally formatting cells in an NSTableView
  • Index(es):
    • Date
    • Thread