Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSTableView: blue outline on right-clicked rows

I'm wondering how I can get rid of the blue outlines that Cocoa draws around rows in NSTableView / NSOutlineView when right-clicking on them.

NSTableView Outline http://tobidobi.com/nstableview_outline.png

It doesn't seem to be a classic "highlight" nor a "focus ring" if I'm not mistaken - so, what is it, actually?

I'm currently drawing custom NSCells completely myself - but I can't figure out how to either
* draw this outline by myself, too, or
* get rid of it, or
* at least change its colour

Any hints are very welcome! Thanks!

like image 822
Tobidobi Avatar asked Nov 18 '10 21:11

Tobidobi


2 Answers

Unfortunately I'm not aware of any documented way to do this, short of writing your own table view replacement.

The method to override is:

- (void)drawContextMenuHighlightForRow:(NSInteger)row;

Please file an enhancement request with Apple so you won't have to rely on undocumented methods to do what you want in future. It looks like the other two table view highlight methods were made customizable in 10.6 but this one wasn't. I've always thought it was a bit clunky looking but it's necessary to indicate what row the menu is referencing (not necessarily the same as the highlighted row).

like image 89
Nicholas Riley Avatar answered Nov 24 '22 12:11

Nicholas Riley


My NSTableView *mainTableView is not sub-classed so I got rid of it just before the contextual menu opens:

- (void)menuWillOpen:(NSMenu *)menu{
     NSInteger rightClicked = [mainTableView clickedRow];
     [mainTableView selectRowIndexes:[NSIndexSet indexSetWithIndex:rightClicked] byExtendingSelection:NO];
     [mainTableView deselectRow: rightClicked];
     [mainTableView reloadData];
    {
like image 33
André Avatar answered Nov 24 '22 12:11

André