Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Setting TableView row background color based on row data

26 views
Skip to first unread message

Luke

unread,
Feb 16, 2023, 6:07:19 AM2/16/23
to Cappuccino & Objective-J
I'm trying to figure out how to programmatically set the background color of a table row (cell based table) based on the row data.

In the past in cocoa, I've used a delegate method to be told when a cell is about to be drawn and then set the background colour, but I think maybe Cappuccino does things a bit differently?


Keary Suska

unread,
Feb 16, 2023, 11:28:53 AM2/16/23
to objec...@googlegroups.com
Many display attributes of controls are managed by an undocumented theming system, and this may be what you are hitting against. It is not terribly hard to figure out what attributes are being applied, but where and when are not always easy (especially with table views) and will likely require subclassing to get the behavior you want.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business”



> On Feb 16, 2023, at 1:07 AM, Luke <luke....@gmail.com> wrote:
>
> I'm trying to figure out how to programmatically set the background color of a table row (cell based table) based on the row data.
>
> In the past in cocoa, I've used a delegate method to be told when a cell is about to be drawn and then set the background colour, but I think maybe Cappuccino does things a bit differently?
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Cappuccino & Objective-J" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to objectivej+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/objectivej/576d077f-5d90-4663-b0b2-6b1d03e1bb02n%40googlegroups.com.

Message has been deleted

Luke

unread,
Feb 17, 2023, 1:21:18 PM2/17/23
to Cappuccino & Objective-J
Sounds like I'll have to scan the cappuccino sources for clues as to how the "undocumented theming system" works for my purposes of simply setting a background 'style' based on a field of the row data. 

In the meantime I thought I'd just use the text color, via the Text Color binding on the TableColumn.  However, when this is set in IB, I get an error "CPTableColumn is not key value coding compliant for the key textColor", so I"m guessing that this binding isn't supported either :( 

Setting the color of the text is such a common thing (you'd think) that it's surely simple to do somehow. (!).  I'll keep looking for clues...

Luke

unread,
Feb 17, 2023, 1:59:35 PM2/17/23
to Cappuccino & Objective-J
Ah, I've found this:
... which suggests a way for me to achieve my original goal of coloring the table row background.  

However, I'm now a bit frustrated by the seemingly even simpler problem of setting the text color discretely in each cell as the table draws.  
Seems to be different to cocoa, but it ought to be easy, so I feel like I'm missing something simple, but haven't yet found any clues in the test sources. 

Luke

unread,
Feb 20, 2023, 11:31:22 PM2/20/23
to Cappuccino & Objective-J
Just to confirm (for the group) that the table row background drawing code (link above) worked really well for me.
Consequently I still don't know (yet) how I'd actually go about discretely changing the text colour in use in a particular table cell in Cappuccino, and therefore whether that necessarily requires doing battle with the "undocumented theming system".  The row background color was sufficient for me to highlight items though, so all good :) 

Reply all
Reply to author
Forward
0 new messages