Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the source lists selection highlight to use the Dark Vibrancy appearance in OS X 10.10?

In OS X 10.10 source lists seem to use the light vibrancy appearance. In the Finder (and in some other third party applications, Things.app for example) the selected item in the source list is indicated by a dark vibrancy appearance. For example, see the Desktop row in the image below.

How can I replicate this behaviour? Do I need to use the delegate methods to specify the table row view,

-outlineView:rowViewForItem:

and attempt custom drawing myself or is there a more straight forward approach? If you make a standard source list UI in Xcode the default highlighting is remain the standard blue rectangle that we have seen in previous version of OS X.

Source list with light vibrancy style, the selected items is darker (using a dark vibrancy style)

like image 469
Daniel Farrell Avatar asked Oct 27 '14 20:10

Daniel Farrell


1 Answers

After playing around for a while I found a way to accomplish this. It turned out that I would get the "Finder highlight" style when using NSTableViewSelectionHighlightStyleSourceList and clicking outside my NSOutlineView. So I figured it would stay that way if you refuse making it first responder.

Simply make your NSOutlineView a subclass and override this method:

-(BOOL)acceptsFirstResponder{
    return NO;
}

It works, but with some downsides. For example, using arrow keys in the NSOutlineView will no longer work. I downloaded the Things app, and it does not allow use of arrow keys either, so it's very likely that this is how they are doing it. If anyone finds a better way, please post it.

like image 90
Oskar Avatar answered Nov 15 '22 23:11

Oskar