NSOutlineView with source highlighting not retreating to the second level

I had a very strange problem:

I have an NSOutlineView set to NSTableViewSelectionHighlightStyleSourceList . Under certain conditions, the second level has no indentation and is displayed at the same level as the root node.

I believe this is because the first level should be "group." However, at 10.8 everything is indented by default. I just caught this when testing on 10.7. It looks like this change has changed in versions.

The second level is not indented if:

  • on Mac OS X 10.7 Lion (always the same behavior)
  • OR only 10.8 if I implement - (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item to return NO

How can I make each level fall back, as one would expect for a hierarchical layout and maintain the style of the original list?

Unexpected indentation:

unexpected indentation

+4
source share
1 answer

Indentation only seems to start at level 3. So, to get around this, you need to add a node that wraps all your current root nodes. This root node will be very similar to the default OSX group node:

enter image description here

Not perfect, depending on your user interface, but better than using the usual NSOutlineView style.

If you do not want to show the root title, you can use outlineView:heightOfRowByItem: to set the height to 0 .

+1
source

Source: https://habr.com/ru/post/1487036/


All Articles