I'm building a macOS app with SwiftUI, and I'm trying to remove (or even cover up) the border added to a List
item when I right-click it.
Here it is by default:
Now with a right-click and a contextMenu
view modifier:
I figured this is an NSTableView
quirk, so I tried the approaches in these three Stack Overflow posts:
- Customize right click highlight on view-based NSTableView
- NSTableView with menu, how to change the border color with right click?
- Disabling the NSTableView row focus ring
- NSTableView: blue outline on right-clicked rows
I couldn't get any of those to work, and that may be due to the fact that I can't subclass an NSTableView
, but can only override its properties and methods with an extension
. Here's what I have so far that successfully removes the default table background and such:
extension NSTableView{
open override func viewDidMoveToWindow() {
super.viewDidMoveToWindow()
//Remove default table styles
backgroundColor = NSColor.clear
enclosingScrollView!.drawsBackground = false
selectionHighlightStyle = .none
}
}
Is there any way to remove that right-click border in SwiftUI? I'm even open to covering it with other views, but I can't seem to draw SwiftUI views in that space around the table cell.