• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTextField: How to DEselect text?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextField: How to DEselect text?


  • Subject: Re: NSTextField: How to DEselect text?
  • From: Jerry Krinock <email@hidden>
  • Date: Thu, 20 Dec 2007 22:31:49 -0800


On 2007 Dec, 20, at 22:12, Shripada Hebbar wrote:

[mWindow makeFirstResponder:mTextField];

//Get hold of the field editor and deselect its text
NSText* fieldEditor = [mWindow fieldEditor:YES forObject:mTextField];
[fieldEditor setSelectedRange:NSMakeRange([[fieldEditor string] length],0)];
[fieldEditor setNeedsDisplay:YES];

Thank you, Shripada. I just figured this out after considering John's reply.


The location member of the range passed to setSelectedRange should be set to the end of the string, as you have done. At first I set the range to {0,0}, but that put the insertion point at the ^beginning^ of the text, which was another ARGHHHH, because there ain't no - setInsertionPoint in any of the related classes.

Apparently, the insertion point is always set to the ^end^ of the selectedRange.

All works now.  Thanks.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTextField: How to DEselect text?
      • From: "Clark Cox" <email@hidden>
    • Re: NSTextField: How to DEselect text?
      • From: John Stiles <email@hidden>
References: 
 >Re:NSTextField: How to DEselect text? (From: Shripada Hebbar <email@hidden>)

  • Prev by Date: Re:NSTextField: How to DEselect text?
  • Next by Date: Re: Opacity of Menus
  • Previous by thread: Re:NSTextField: How to DEselect text?
  • Next by thread: Re: NSTextField: How to DEselect text?
  • Index(es):
    • Date
    • Thread