Search code examples
objective-cmacoscore-animationnsoutlineviewnscell

Core Animation causing partial Source List focus ring


I'm using a slightly modified ImageAndTextCell from one of Apple's tutorials in a custom NSOutlineView. For those unfamiliar with it, it's an NSTextFieldCell subclass that draws an image to the left of the cell's text.

I have a Source List like iTunes's, with group rows, and items beneath. While editing the cell's value, the focus ring only draws partially for the group's first two rows (see below). The top third of the focus ring draws in the first row, and the bottom third draws in the second row.

Subsequent rows draw fine (see the third row below), and they all have the same image. What could be causing this? (See Update 3 below. Core Animation is causing this behavior)

enter image description here enter image description here enter image description here

Update 1

I commented out virtually all custom code in ImageAndTextCell and it made no difference (Only init, dealloc, copyWithZone, and the image getter and setter remained).

Update 2

I commented virtually all code in the NSOutlineView subclass, and my delegate class, as well as keeping all code from Update 1 commented out - still strange results. The third row is no longer always perfect, but the portions of the focus rect drawn shifted as I removed various functions.

Also, the items I'm having problems with are in the second of my two outline groups. When renaming the only item in the first group, the focus rect was perfect every step of the way. Ironically, this is the one that can't be renamed during standard operation of my app.

Next I'll take a look at all of my settings in the NIB and see if something might be broken there.

Update 3

I was able to fix it by disabling Core Animation across the board for every view in my window. The question has now become: How do I re-enable Core Animation without making my focus rects look crappy?


Solution

  • Not having solved this before moving to Lion, I can now happily report that switching to a view-based NSOutlineView fixes this problem. Oddly, if you turn on layer-backing in IB for the outline view, it creates other problems. The interface still animates, however, after unchecking those boxes (and has support for far richer animations than the cell-based outline view).