Search code examples
objective-ccocoansoutlineview

Incorrect margins on NSOutlineView SourceList view


A problem that has vexed me ever since Lion was released is the margin/indent on row items of the preformatted NSOutlineView view-based "SourceList" control. Despite all of my best attempts to correct the margins, Apple's built-in formatting takes over and positions the views regardless of what I've specified (whether through the indentation setting or manually moving views).

Here's a picture to demonstrate:

enter image description here

How might I be able to fix this without resorting to doing everything manually?


Solution

  • Subclass NSOutlineView and override -frameOfOutlineCellAtRow: and frameOfCellAtColumn:row: to adjust the disclosure triangle, and text and images respectively. Call through to super for the actual cell's frame and assign the x-origin of the cell 3 pixels farther to the right in both cases.