• 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: Color entire table view row
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Color entire table view row


  • Subject: Re: Color entire table view row
  • From: David Remahl <email@hidden>
  • Date: Fri, 05 Apr 2002 09:33:43 +0200

Before I read your original post:

NSCell has methods for setting an attributed string.

@interface NSCell(NSCellAttributedStringMethods)
- (NSAttributedString *)attributedStringValue;
- (void)setAttributedStringValue:(NSAttributedString *)obj;
/* These methods determine whether the user can modify text attributes and
import graphics in a rich cell. Note that whatever these flags are, cells
can still contain attributed text if programmatically set. */
- (BOOL)allowsEditingTextAttributes;
- (void)setAllowsEditingTextAttributes:(BOOL)flag; /* If NO, also clears
setImportsGraphics: */
- (BOOL)importsGraphics;
- (void)setImportsGraphics:(BOOL)flag; /* If YES, also sets
setAllowsEditingTextAttributes: */
@end

They should allow you to get the work done...There is also a method for
setting the font used.

----CUT----

After I read your initial post:

Your task seems better fit for a formatter, don't you think? You will have
to implement the formatter calling yourself from your datasource still, and
still set the attributed string, but the final solution will be a bit more
portable and encapsulated in a familiar interface.

/ David Remahl

> Hi,
>
> Sorry to burst your bubble, but I want to color the text in a row, not a
> column.
>
> Seems there's really no elegant way to do this.
>
>
> On 4/4/02 9:49pm, "email@hidden"
> <email@hidden> wrote:
>> From: Matt Massicotte <email@hidden>
>> Date: Thu, 4 Apr 2002 21:46:24 -0500
>> To: email@hidden
>> Cc: email@hidden
>> Subject: Re: Color entire table view row
>>
>> Finally!
>>
>> A question that *I* actually know the answer to! I'm happy to report
>> that I have implemented this myself quite effectively. I'm sure that
>> it's not the best way to do it, so maybe some of the more experienced
>> guys can give us both a hand :)
>>
>> What I did was subclass NSTableColumn and change the columns in IB to my
>> subclass. The actual subclass simply keeps an array of cells (instead
>> of one single data cell) and overrides the methods that interact with
>> the data cell.
>>
>> In order to ensure that my column has the right number of cells, I
>> adjust the number of cells every time my datasource's
>> numberOfRowsInTableView method is called.
>>
>> Now, you can set the text color of the cells to your heart's content.
>>
>> This works rather well for me (although I have noticed that if you have
>> multiple columns, and you only change one to your subclass, other rows
>> get colorized and I'm not sure why)
>>
>> So, I hope this points you in the right direction
>> Matt Massicotte
_______________________________________________
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.

  • Follow-Ups:
    • Re: Color entire table view row
      • From: "Erik J. Barzeski" <email@hidden>
References: 
 >Re: Color entire table view row (From: "Erik J. Barzeski" <email@hidden>)

  • Prev by Date: Re: Making Array Pointers Global
  • Next by Date: Re: Color entire table view row
  • Previous by thread: Re: Color entire table view row
  • Next by thread: Re: Color entire table view row
  • Index(es):
    • Date
    • Thread