On Jul 26, 2015, at 7:25 AM, 2551 <[email protected]> wrote:

> I’ve been struggling with NSTableView for the last two days. All I want to do 
> is ensure the alternative “gray” highlight is used on a selection 
> consistently instead of the heavy blue.

My first question is why do you want to trick your uses into seeing your table 
as being in a non-key window?  If you're going to use a non-standard selection 
highlight, you should use a different color entirely, one that doesn't have 
strong connotations already.


> I’ve seen SE posts suggesting subclassing NSTableRowView, but I don’t 
> understand why, since the property setEmphasized already exists in the parent 
> class and should work across the board (shouldn’t it??).

That setter is used by Cocoa itself to inform the row view whether it is 
emphasized (in the key window).  If you call it yourself, you have no guarantee 
(as you've seen) that your value won't be replaced by Cocoa at some point.

The right approach is to subclass NSTableRowView.  It's not hard.  Why do you 
resist it?

You could have your subclass override the emphasized property to always return 
false, but I'm not sure that's best.

You could also override -drawSelectionInRect:, which is precisely for 
customizing how the selection is drawn.  If you do that, you should also 
override -interiorBackgroundStyle to return an appropriate value (generally 
NSBackgroundStyleLight).  Otherwise, it will return NSBackgroundStyleDark for a 
selected and emphasized row, which will cause text fields to draw white.

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to