views:

77

answers:

2

Hey experts,

when I click on the header of an NSTableView column, the header gets blue and the little grey arrow shows up. How do I avoid the blue selection and the arrow (but keeping the sorting itself)?

As an example for what I want: In Xcode click on the 'Groups & Files' header.

Thank your for any help!

A: 

You can control what shows in the indicator with NSTableView's instance method "setIndicatorImage:inTableColumn:". I don't know if there's a way to just change the highlight as easily.

You can get more control, including the highlight if you subclass NSTableViewCell and override the methods "drawSortIndicatorWithFrame:inView:ascending:priority:" and/or "highlight:withFrame:inView" to control both the indicator element and highlighting. Then you can use this in your table column like so:

NSTableHeaderCell *headerCell = [[[CustomHeaderCell alloc] init] autorelease];
[tableColumn setHeaderCell:headerCell];
charlie hwang
+1  A: 

If you are working with a multi-column table you should never try to disable the arrow and highlighting, how else is the user going to know what the sorting is... If you are working with a single column table (in a source list manner) then lose the header and go with the source list style for the table. Before deciding to override standard behavior you should read the Apple interface guidelines and consider if you really need override those behaviors. For the record Xcode's Groups & Files doesn't sort and that is why it doesn't turn blue or get an arrow.

theMikeSwan