Reputation: 9576
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.
Upvotes: 2
Views: 1722
Reputation: 85955
If your goal is just displaying a contextual menu, you also can try this.
NSOutlineView
within another NSView
. menuForEvent
method on the wrapper view. 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.
Upvotes: 0
Reputation: 4966
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
Upvotes: 2
Reputation: 2960
Subclass the table view and implement the following method:
- (void)drawContextMenuHighlightForRow:(NSInteger)row {
// do nothing
}
Note:
Upvotes: 3