cocoanstableviewnscell

Marking rows in NSTableView as dirty


I subclassed NSTextFieldCell to do custom drawing and highlighting. I am essentially making a table with cells similar to the one found in Lion Mail, but my code is targeting Snow Leopard. The problem that I'm running into is this:

  1. user selects a cell (my cell draws a custom highlight)
  2. user scrolls the selected cell and all previously visible cells so that they are no longer visible in the table
  3. user selects an unselected cell (the new cell is highlighted)
  4. user scrolls the table such that the initially selected cell is visible again in the table

The last step is where the problem occurs; the initially selected cell is not being redrawn even though it is no longer selected. The consequence is that the cell appears to be selected.

What do I have to do to signal that unselected cells must be marked as dirty?


Solution

  • Use the selector setNeedsDisplay:.