Now I'm all confused. Everything's working now where it wasn't before.

I'm having the desired result (selected cell not appearing selected) by
following Corbin's original advice:

override NSTable's -hightlightSelectionInClipRect: to do nothing & having
the delegate method
- tableView:willDisplayCell:forTableColumn:row:   perform setHighlighted:NO
& setBackgroundStyle:NSBackgroundStyleLight on the cell.

I'm getting backColor text as desired.

Also, if I send [cell setHighlighted:NO], the cell's
-highlightColorWithFrame:controlView: is not called, shao wholesale
subclassing of cells does not appear to be needed.

My guess as to what I had wrong before was that I had set hightlight style
to "source list" in IB when exploring & had not set it back to normal. I'm
testing now with a programmaticly generated NSTableView.

Thanks for all your help.

Kent

On Fri, Mar 12, 2010 at 3:48 PM, Keith Blount <keithblo...@yahoo.com> wrote:

> Actually, after testing this, does overriding NSCell's
> -highlightColorWithFrame:controlView: really have the same effect as
> overriding the _highlightColorForCell: private message? I assume the latter
> just calls the former, but I must be doing something wrong because
> overriding -highlightColorWithFrame: didn't have the desired effect for me.
> Please see the following demo project:
>
> http://www.literatureandlatte.com/misc/BlackSelectedTableText.zip
>
> Note that in that simple project, MyTextFieldCell overrides
> -highlightColorWithFrame:controlView: to return nil (and there is an NSLog
> in there to ensure it is getting called), but although doing so prevents the
> highlight colour from getting drawn, the text still gets drawn in white
> (even though the -willDisplayCell: delegate method in MyDocument is setting
> it to black). Contrast this with uncommenting the _highlightColorForCell:
> method that returns nil in MyTableView, which has the desired effect of
> ensuring the text gets drawn in black (which is what the op was after and is
> the reason I ended up resorting to this private message).
>
> Am I missing something obvious? Is there something else that needs to be
> used in conjunction with this to force the text to be drawn in black even
> when highlighted? (To put this in context, I use NSOutlineView to provide an
> OmniOutliner-style outline with a light blue selection, so the text needs to
> be black even when highlighted given the light highlight, which is
> custom-drawn.)
>
> Many thanks and all the best,
> Keith
>
>
> ----- Original Message ----
> From: Corbin Dunn <corb...@apple.com>
> To: Keith Blount <keithblo...@yahoo.com>
> Cc: cocoa-dev@lists.apple.com; k...@khauser.net
> Sent: Fri, March 12, 2010 11:29:08 PM
> Subject: Re: [NSTableview] can't make selected text stay black
>
> >
> > 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. :)
>
> Thank you for logging the bug -- I do realize we could make this better.
> Currently, there is a way to do it (override highlightColorWithFrame:), so
> adding the requested method is "nice to have", but not essential.
>
> corbin
>
>
>
>
_______________________________________________

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