Re: Is it possible to set an NSTableView cell background color?

2017-02-23 Thread David Delmonte
I worked the problem. I’m rather rusty these days.

This is what I came up with:

1. Moved to view-based table view.

2. In viewForRow, I added this line:

 cell.memoryName.drawsBackground = true

3. And then:

 cell.memoryName.backgroundColor = mintGreen

Thanks to all for the pointers.


> On Feb 23, 2017, at 5:11 PM, corbin dunn  wrote:
> 
> 
>> On Feb 22, 2017, at 6:27 PM, David Delmonte  wrote:
>> 
>> I tried you solution but it doesn’t color the cell. Scratching my head some 
>> more.. I’ll probably ask on Stack Overflow.
> 
> How did you get it to compile?  It requires a view based tableview. Your 
> first step is to convert to a view based tableview.
> 
> corbin
> 
>> 
>> 
>>> On Feb 22, 2017, at 8:37 PM, Saagar Jha  wrote:
>>> 
>>> Well, assuming you have a NSTableCellView, you can set its background color 
>>> using its layer. For example:
>>> 
>>> cell.layer.backgroundColor = NSColor.black.cgColor
>>> 
>>> Saagar Jha
>>> 
 On Feb 22, 2017, at 16:14, David Delmonte > wrote:
 
 Hi all, I have a table that has records by date. I want to color those 
 entries based on the decade.
 
 I cannot seem to find a way to do this.
 
 Any help would be appreciated.
 
 David
 ___
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Is it possible to set an NSTableView cell background color?

2017-02-23 Thread corbin dunn

> On Feb 22, 2017, at 6:27 PM, David Delmonte  wrote:
> 
> I tried you solution but it doesn’t color the cell. Scratching my head some 
> more.. I’ll probably ask on Stack Overflow.

How did you get it to compile?  It requires a view based tableview. Your first 
step is to convert to a view based tableview.

corbin

> 
> 
>> On Feb 22, 2017, at 8:37 PM, Saagar Jha  wrote:
>> 
>> Well, assuming you have a NSTableCellView, you can set its background color 
>> using its layer. For example:
>> 
>> cell.layer.backgroundColor = NSColor.black.cgColor
>> 
>> Saagar Jha
>> 
>>> On Feb 22, 2017, at 16:14, David Delmonte >> > wrote:
>>> 
>>> Hi all, I have a table that has records by date. I want to color those 
>>> entries based on the decade.
>>> 
>>> I cannot seem to find a way to do this.
>>> 
>>> Any help would be appreciated.
>>> 
>>> David
>>> ___


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Is it possible to set an NSTableView cell background color?

2017-02-22 Thread Quincey Morris
On Feb 22, 2017, at 17:45 , David Delmonte  wrote:
> 
> It's cell based!

In that case, you need to implement the delegate method 
"tableView(_:willDisplayCell:for:row:)”, which is called once for each cell 
that’s redrawn.

In your method, you need to verify that the cell is of the type you expect (a 
NSTextFieldCell, I’m guessing), cast it to the correct type, and then set its 
backgroundColor property. Note that NSCell does not itself have such a 
property, it’s only implemented by specific subclasses.

Alternatively, it is possible to prepare one cell per color at initialization, 
then supply the correctly colored cell at each row/column. This is slightly 
more efficient, because it doesn’t involve re-configuring the cell each time 
it’s used, but it’s a bit more code (also in the delegate).




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Is it possible to set an NSTableView cell background color?

2017-02-22 Thread David Delmonte
I tried you solution but it doesn’t color the cell. Scratching my head some 
more.. I’ll probably ask on Stack Overflow.


> On Feb 22, 2017, at 8:37 PM, Saagar Jha  wrote:
> 
> Well, assuming you have a NSTableCellView, you can set its background color 
> using its layer. For example:
> 
> cell.layer.backgroundColor = NSColor.black.cgColor
> 
> Saagar Jha
> 
>> On Feb 22, 2017, at 16:14, David Delmonte > > wrote:
>> 
>> Hi all, I have a table that has records by date. I want to color those 
>> entries based on the decade.
>> 
>> I cannot seem to find a way to do this.
>> 
>> Any help would be appreciated.
>> 
>> David
>> ___
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com 
>> )
>> 
>> Please do not post admin requests or moderator comments to the list.
>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com 
>> 
>> 
>> Help/Unsubscribe/Update your Subscription:
>> https://lists.apple.com/mailman/options/cocoa-dev/saagar%40saagarjha.com 
>> 
>> 
>> This email sent to saa...@saagarjha.com
> 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Is it possible to set an NSTableView cell background color?

2017-02-22 Thread David Delmonte
It's cell based!

> On Feb 22, 2017, at 20:38, Quincey Morris 
>  wrote:
> 
>> On Feb 22, 2017, at 16:14 , David Delmonte  wrote:
>> 
>> I have a table that has records by date. I want to color those entries based 
>> on the decade.
> 
> NSCell-based or NSView-based?
> 
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Is it possible to set an NSTableView cell background color?

2017-02-22 Thread Quincey Morris
On Feb 22, 2017, at 16:14 , David Delmonte  wrote:
> 
> I have a table that has records by date. I want to color those entries based 
> on the decade.

NSCell-based or NSView-based?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Is it possible to set an NSTableView cell background color?

2017-02-22 Thread Saagar Jha
Well, assuming you have a NSTableCellView, you can set its background color 
using its layer. For example:

cell.layer.backgroundColor = NSColor.black.cgColor

Saagar Jha

> On Feb 22, 2017, at 16:14, David Delmonte  wrote:
> 
> Hi all, I have a table that has records by date. I want to color those 
> entries based on the decade.
> 
> I cannot seem to find a way to do this.
> 
> Any help would be appreciated.
> 
> David
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/saagar%40saagarjha.com
> 
> This email sent to saa...@saagarjha.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Is it possible to set an NSTableView cell background color?

2017-02-22 Thread David Delmonte
Hi all, I have a table that has records by date. I want to color those entries 
based on the decade.

I cannot seem to find a way to do this.

Any help would be appreciated.

David
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com