title: NSTableRowView not calling DrawBackground correctly during drag-drop operations
body: <p>I have an NSTableView with a set of rows. There are two types of rows - titles and data - which are displayed differently.</p>
  
  <p>I am dragging an object from within my app onto the data rows. Drag and drop works fully and only data rows accept the drop - but there is a display issue.</p>
  
  <p>I am using a custom NSTableRowView, and what I expect to see is that if I drag my object over a data row, then <code>DrawDraggingDestinationFeedback</code> should be called (it is) to draw my custom background used during drag operations. If I then drag my object out of the data row, I expect <code>DrawBackground</code> to be called (it is SOMETIMES) to redraw my standard background.</p>
  
  <p>Heres the detail:</p>
  
  <p>If I drag my object onto a data row and then completely away from the NSTableView, <code>DrawDraggingDestinationFeedback</code> is called on entry and <code>DrawBackground</code> is called on exit.</p>
  
  <p>If I drag my object onto a row, and then <em>down</em> to the next row, 
  <code>DrawDraggingDestinationFeedback</code> is called for the top row, then when I move down  <code>DrawDraggingDestinationFeedback</code> is called for the lower row, but <code>DrawBackground</code> is <em>not</em> called for the first row (i.e. its background color is not reset). This leaves BOTH rows looking like they are active drop destinations.</p>
  
  <p>Weirdly, the final <code>DrawBackground</code> on exiting the table is called.</p>
  
  <p><a href="https://i.stack.imgur.com/gWXK3.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gWXK3.gif" alt="Showing missing calls to DrawDraggingDestinationFeedback"></a></p>
  
  <p>Here is my custom NSTableRowView:</p>
  
  <pre><code>       public class CustomSelectionRowView : NSTableRowView
      {
          /// The log object
          private static Logger log = LogManager.GetCurrentClassLogger();
  
          private string type;
          private DataItem ditem;
  
          public CustomSelectionRowView(string type, DataItem ditem = null) : base()
          {
              this.type = type;
              this.ditem = ditem;
              DraggingDestinationFeedbackStyle = NSTableViewDraggingDestinationFeedbackStyle.Regular;
              SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.Regular;
          }
  public override void DrawDraggingDestinationFeedback(CGRect dirtyRect)
          {
              log.Debug(ditem.title);
              if (type == "Data")
              {
                  //  This can accept a drag-drop
                  var color = NSColor.Gray;
                  var p = NSGraphicsContext.CurrentContext.GraphicsPort;
                  p.SetFillColor(color.CGColor);
                  p.FillRect(dirtyRect);
              }
              else
                  base.DrawDraggingDestinationFeedback(dirtyRect);
          }
  
          public override void DrawBackground(CGRect dirtyRect)
          {
              log.Debug(ditem.title);
              if (type == "Data")
              {
                  //  We definitely have a Data block
                  var color = NSColor.FromName("MainPaneDataBackground");
                  var p = NSGraphicsContext.CurrentContext.GraphicsPort;
                  p.SetFillColor(color.CGColor);
                  p.FillRect(dirtyRect);
  
              }
  
              else 
                  base.DrawBackground(dirtyRect);
  
          }
     }
  
  </code></pre>
  
  <p>Anyone have any ideas of how to work around this?
  Many thanks. </p>
  
  <p>[p.s. note that while my code here is C#/Xamarin... any swift help would be gratefully accepted - I speak both]</p>