Search code examples
appkitnsoutlineviewmacos-big-sur

Hide Default NSOutlineView Expand/Collapse Arrows in Big Sur


Prior to macOS Big Sur, I could create an NSOutlineView and hide the default show/hide arrows that expand and collapse groups of items. But now in Big Sur, I can't find any way to get rid of the default arrows. I'm using my own arrow style and functionality.

Here's a screenshot:

enter image description here

I have my NSOutlineView set to have a Plain Style since I also provide my own margins around the rows. But I don't see any options in the storyboard editor for hiding the arrows, nor do I see any options under NSOutlineView in the docs for doing it.

Does anyone know how to hide the default expand/collapse arrows in Big Sur?


Solution

  • A reliable way of customizing the disclosure button for NSOutlineView is to subclass NSOutlineView and override a couple key methods. First, override frameOfOutlineCellAtRow: to reposition the arrow where you want. Then, override makeViewWithIdentifier: to customize the view that actually implements the arrow. You can identify it with the identifier NSOutlineViewDisclosureButtonKey.

    Achieving the goal in this way is probably both more reliable than however you were doing it before, and likely to be more consistent for technologies like accessibility screen readers.