Search code examples
cocoanstableviewnsoutlineview

Can't change column width in response to outlineViewItemDidExpand


I want to update the column width to the width of the widest entry whenever a node in my NSOutlineView is expanded. Thus, my delegate listens to outlineViewItemDidExpand and calls

[column setWidth:maxColumnWidth];

in it. maxColumnWidth is the width of the widest entry.

However, for some reason, calling setWidth from inside outlineViewItemDidExpand doesn't seem to do anything. When I call it later, e.g. as a response to a button click, it works just fine, but from within outlineViewItemDidExpand it just does nothing.

So any idea what I could do to update the column width whenever the user clicks on an expander icon? Thanks a lot!


Solution

  • If autoresizesOutlineColumn is YES (default) then the outline view resizes the outline column after outlineViewItemDidExpand. Solution: set autoresizesOutlineColumn to NO.