How do you disable the focus ring around an NSTableView
row when the user right-clicks on it? I can't get it to disappear. Setting focus ring of an individual NSTableViewCell
in the table to None
has no effect.

- 9,416
- 14
- 78
- 129
-
Where did you try to change the Focus Ring to None? – Dejan Skledar Jun 02 '15 at 07:18
-
On TableViewCells in IB and via shouldEditTableColumn in my table's delegate. – BadmintonCat Jun 02 '15 at 11:04
-
Did you check if the method is even called ? – Dejan Skledar Jun 02 '15 at 11:04
-
Nope. but I did now. And it isn't called! – BadmintonCat Jun 02 '15 at 11:06
-
https://stackoverflow.com/questions/9619664/customize-right-click-highlight-on-view-based-nstableview/53315864#53315864 – MCMatan Nov 15 '18 at 09:16
3 Answers
Subclass the table view and implement the following method:
- (void)drawContextMenuHighlightForRow:(NSInteger)row {
// do nothing
}
Note:
- The blue outline is not the focus ring.
- This is an undocumented private method Apple uses to draw the outline. Providing an empty implementation will prevent anything from being drawn, but I am not 100% sure that whether it can pass the review.

- 2,941
- 2
- 25
- 30
New:
Here is how I did it.
You can handle the menu manually. Subclass NSTableRowView
or NSTableCellView
, then use rightMouseDown:
and mouseDown:
(check for control key) and then notify your tableViewController (notification or delegate) of the click. Don't forget to pass the event as well, then you can display the menu with the event on the table view without the focus ring.
The above answer is easier, but it may not pass the review, as the author mentioned.
Plus you can show individual menu items for each row (if you have different sorts of views)
Old:
I think the focus ring is defined by NSTableRowView
, not NSTableCellView
, because it is responsible for the complete row. Try to change the focus ring there. You can subclass NSTableRowView
and add it to the tableView via IB or NSTableViewDelegate
's method:
- (NSTableRowView *)tableView:(NSTableView *)tableView rowViewForRow:(NSInteger)row

- 4,746
- 2
- 26
- 50
-
Ok but the question is how do I change the focus ring in the NSTableRowView subclass? There seems to be no property for that. – BadmintonCat Jun 02 '15 at 11:05
-
I tried to replicate what you are doing. How do you implement the secondary click? Because I did not get any focus ring at all. – mangerlahn Jun 02 '15 at 11:20
-
-
I've added a context menu to my table's view controller in IB and wired it up there (menu, delegate, actions) and that's how the right click context menu works. – BadmintonCat Jun 02 '15 at 12:13
-
Ok, sorry. I did not know there was a menu property on `NSTableView`. I did handle the right click completely different. – mangerlahn Jun 02 '15 at 12:48
If your goal is just displaying a contextual menu, you also can try this.
- Wrap the
NSOutlineView
within anotherNSView
. - Override
menuForEvent
method on the wrapper view. - Do not set
menu
on outline-view.
Now the wrapper view shows the menu instead of your outline-view, so it won't show the focus ring. See How do you add context senstive menu to NSOutlineView (ie right click menu) for how to find a node at the menu event.