title: Deselect text in an NSTextView programmatically?
body: <p>I am using the following code to deselect an <code>NSTextView</code>, as suggested <a href="http://www.cocoabuilder.com/archive/cocoa/195313-nstextfield-how-to-deselect-text.html" rel="noreferrer">here</a>. Unfortunately, nothing at all happens. I have tried what I know to debug it, but everything seems to be working correctly, but it doesn't affect the <code>NSTextView</code>.</p>
  
  <p>The code:</p>
  
  <pre><code>// Sets the scrolling bounds and behavior. This might be useful, but I don't know
  [[textView textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)];
  [[textView textContainer] setWidthTracksTextView:FALSE];
  
  // The code for deselecting, beginning by making sure it is actually selected (for testing only, as strange as it is)
  
  [textView setSelectable:TRUE];
  [textView setDelegate:self];
  [_window makeFirstResponder:textView];
  
  NSText *fieldEditor = [_window fieldEditor:TRUE forObject:textView];
  [fieldEditor setSelectedRange:NSMakeRange([[fieldEditor string] length],0)];
  [fieldEditor setNeedsDisplay:YES];
  </code></pre>
  
  <p>Any ideas about why this doesn't work? I am sure my outlets are set properly because I can manipulate other things, such as it's string value.</p>