Keith,

Your solution was perfect. (It didn't work at first, but that's because I
had somehow left HighlightStyle as source list in IB while I was trying
everything. Per your note, the first thing I checked & then perfection.)

As you mention, overriding -highlightSelctionInClipRect is unneeded. I also
can get away with leaving out the [cell setTextColor:[NSColor blackColor]]
as long as I set the background style -- but I'm testing on 10.6 and who
knows about 10.5 and it can't hurt.

Thanks for the pointer. A five-minute task turned out to be anything but...

Kent

On Tue, Mar 9, 2010 at 8:37 AM, Keith Blount <keithblo...@yahoo.com> wrote:

> Hi,
>
> Actually the only way I know of doing this pre-10.6 is to override
> NSTableView's private _highlightColorForCell: method to return nil. Even if
> you override -highlightSelectionInClipRect: to do nothing, the cell drawing
> will still use the highlight colour returned from this private method.
>
> So the correct settings pre-10.6 are:
>
> The table view's selectionHighlightStyle must be set to
> NSTableViewSelectionHighlightStyleRegular (if it's set to source list style,
> NSTableView seems to do things completely differently).
>
> In your table view delegate's -
> tableView:willDisplayCell:forTableColumn:row: method, set the cell
> background style to light and the text colour to black:
>
> [aCell setBackgroundStyle:NSBackgroundStyleLight];
> [aCell setTextColor:[NSColor blackColor]];
>
> Then, in your NSTableView subclass, have the private method return nil:
>
> - (id)_highlightColorForCell:(NSCell *)cell
> {
> return nil;
> }
>
> (You can also override -highlightSelectionInClipRect: to do nothing just to
> be sure, but the above should be all it takes.)
>
> That should have the effect you're after.
>
> Hope that helps.
> All the best,
> Keith
>
> P.S. I'm hesitant about mentioning private methods here, but I don't think
> there's another way of doing it - I filed an enhancement request for this
> method to be made public back in April '06, ID#4521167, so please do the
> same if you think it would be useful. I'm CC'ing Corbin so he can straighten
> me out on the private method thing if this is totally the wrong advice, but
> it works for me. :)
> On Mar 5, 2010, at 2:25 PM, Kent Hauser wrote:
>
> > Hi,
> >
> > I'm trying to make a NSTableView selected row not look selected. I
> > subclassed NSTableView & added the following class & delegate methods:
> >
> > // remove selection indication
> > - (void)highlightSelectionInClipRect:(NSRect)clipRect
> > {
> >    NSLog (@"%s", __FUNCTION__);
> > }
> >
> > // change selected cell text color (delegate method)
> > - (void)tableView:(NSTableView *)tableView willDisplayCell:(id)cell
> > forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)rowIndex
> > {
> >    NSLog (@"%s", __FUNCTION__);
> >    if ([cell respondsToSelector:@selector(setTextColor:)])
> >        [(id)cell setTextColor:[NSColor blackColor]];
> > }
> >
> > While the "hightlightSelection" method does it's job, my delegate method
> > doesn't paint the text black. (However, if I use redColor, I get red
> text).
> >
> > What am I missing
>
>
>
>
_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Reply via email to