This is my first question here, and I will try to do it as clear as possible.

I want to draw a custom gradient on a selected row in a view-based NSTableView, while adding a subtle raised effect. For this, I need to use a darker color for the grid-lines that are before and after the selected row (see here for an example). I have overrode drawSeparatorInRect: method in NSTableRowView to draw the custom separator line for the selected row (using isSelected method as a flag), but I cannot do the same for the above/below one (since I draw the line at the bottom/top).

I have tried several ways to tell the closest row that it should draw a darker separator line with no success since the display step does not follow the same order (I checked it with NSLogs in the drawSeparatorInRect:, and it seems that when you scroll a little this order changes). So, sometimes (mostly after scrolling) the row doesn't know that it should use a darker color since it draws itself before the selected one (I think at this point, the selected-row is not aware yet that it's selected, otherwise I don't understand what is going on).

Some of the things I tried:

  1. In the drawSeparatorInRect: method of the selected row, I have tried to access to the siblings views ([superview subviews]) and force the previous/next one to draw itself again.
  2. From the NSTableView subclass, modify directly the closest row when the selectedIndexes change.
  3. Drawing the line outside the selected row from within its drawSeparatorInRect: method as showing here.

Note that I did this having: a row view asking if the previous/next one is selected, a closestRowIsSelected flag

Edit
Report