title: NSTableView: How to draw a custom separators before and after a selected row
body: <p>This is my first question here, and I will try to do it as clear as possible.</p>
  
  <p>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 <a href="http://cl.ly/1F0s2V161h1a2N3x1w0o" rel="nofollow noreferrer">here</a> for an example). I have overrode <code>drawSeparatorInRect:</code> method in <strong>NSTableRowView</strong> to draw the custom separator line for the selected row (using <code>isSelected</code> method as a flag), but I cannot do the same for the above/below one (since I draw the line at the bottom/top).</p>
  
  <p>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 <code>drawSeparatorInRect:</code>, 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).</p>
  
  <p>Some of the things I tried:</p>
  
  <ol>
  <li>In the <code>drawSeparatorInRect:</code> method of the selected row, I have tried to access to the siblings views (<code>[superview subviews]</code>) and force the previous/next one to draw itself again.</li>
  <li>From the <code>NSTableView</code> subclass, modify directly the closest row when the <em>selectedIndexes</em> change.</li>
  <li>Drawing the line outside the selected row from within its <code>drawSeparatorInRect:</code> method as showing <a href="https://stackoverflow.com/questions/4533816/gap-above-nsmenuitem-custom-view">here</a>.</li>
  </ol>
  
  <p>Note that I did this having: a row view asking if the previous/next one is selected, a <em>closestRowIsSelected</em> flag or externally calling a method to "force" the dark color.</p>
  
  <p>What I have now is that the selected row draws both top and bottom borders, so one of them is placed together to the previous/next row line... It's subtle but it still there.</p>
  
  <p>Any help will be well received.</p>
  
  <p>Thank you in advance.</p>
  
  <p><strong>!</strong> I didn't post any code since the problem is not there (it just calls <code>[NSBezierPath fillRect:rect]</code> with red color), I think... so I have nothing to show.</p>