title: dragging text produces 2 insertion points in NSTextView, and can not remove it
body: <p>This is the error picture:</p>
  <p><a href="https://i.stack.imgur.com/jvO8u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jvO8u.png" alt="enter image description here" /></a></p>
  <p>My class is a subclass of NSTextView, it supports dragging. but When I drag text to former location, there will be a sticked inserting point.</p>
  <p>Then I click elsewhere ,the normal insertion point appears at the end of text(which is correct),</p>
  <p>but the first point did not disappear automatically, even though I delete the whole string.</p>
  <p>there are only 3 method or property in NSTextView related to insertion point.</p>
  <pre><code>@property (readonly) BOOL shouldDrawInsertionPoint;
  @property (copy) NSColor *insertionPointColor;
  
  - (void)updateInsertionPointStateAndRestartTimer:(BOOL)restartFlag;
  - (void)drawInsertionPointInRect:(NSRect)rect color:(NSColor *)color turnedOn:(BOOL)flag;
  </code></pre>
  <p>The first one is readonly, I tried the second one ,I set white color, when dragging and original color after dragActionEnded. I did not work.</p>
  <p>Waiting for your resolution.
  Thanks!</p>
  <p>The following is the drag delegate code I wrote.
  #pragma mark - Destination Operations</p>
  <pre><code>- (NSDragOperation)draggingEntered:(id &lt;NSDraggingInfo&gt;)sender
  </code></pre>
  <p>{
  /<em>------------------------------------------------------
  method called whenever a drag enters our drop zone
  --------------------------------------------------------</em>/</p>
  <pre><code>// Check if the pasteboard contains image data and source/user wants it copied
  if ([sender draggingSourceOperationMask] &amp; NSDragOperationCopy )
  {
      //accept data as a copy operation
      return NSDragOperationCopy;
  }
  
  return NSDragOperationNone;
  </code></pre>
  <p>}</p>
  <pre><code>- (BOOL)prepareForDragOperation:(id &lt;NSDraggingInfo&gt;)sender
  </code></pre>
  <p>{</p>
  <pre><code>//check to see if we can accept the data
  NSURL *fileURL=[NSURL URLFromPasteboard: [sender draggingPasteboard]];
  if (fileURL == nil) {
  return NO;}
  NSString *filePathAndName = [[NSString alloc] initWithUTF8String:[fileURL fileSystemRepresentation]];
  if (filePathAndName == nil)
  {
      return NO;
  }
  
  NSString *fileExtension = [[filePathAndName pathExtension] uppercaseString];
  if (fileExtension == nil)
  {
      return NO;
  }
  
  if ([fileExtension isEqualToString:@&quot;JPG&quot;] ||
      [fileExtension isEqualToString:@&quot;JPEG&quot;] ||
      [fileExtension isEqualToString:@&quot;PNG&quot;] ||
      [fileExtension isEqualToString:@&quot;GIF&quot;] ||
      [fileExtension isEqualToString:@&quot;BMP&quot;])
  {
      return YES;
  }
  else
  {
      return NO;
  }
  </code></pre>
  <p>}</p>
  <pre><code>- (BOOL)performDragOperation:(id &lt;NSDraggingInfo&gt;)sender{
  
  if ( [sender draggingSource] != self )
  {
      
  if ( [[[sender draggingPasteboard] types] containsObject:NSFilenamesPboardType] ) {
  NSURL* fileURL=[NSURL URLFromPasteboard: [sender draggingPasteboard]];
          NSArray *files = [[sender draggingPasteboard] propertyListForType:NSFilenamesPboardType];
          [[NSNotificationCenter defaultCenter] postNotificationName:ZayhuSendPicToPeer object:self userInfo:@{@&quot;filesArray&quot;:files}];
      }
  }
  
  return YES;
  </code></pre>
  <p>}</p>
  <pre><code>- (NSString *)preferredPasteboardTypeFromArray:(NSArray *)availableTypes restrictedToTypesFromArray:(NSArray *)allowedTypes{
  if ([availableTypes containsObject:NSPasteboardTypeString])
  {
      return NSPasteboardTypeString;
  }
  return [super preferredPasteboardTypeFromArray:availableTypes restrictedToTypesFromArray:allowedTypes];
  </code></pre>
  <p>}</p>