• 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: Shripada Hebbar <email@hidden>
  • Date: Fri, 21 Dec 2007 11:42:42 +0530

Hi Jerry

You need to get hold of the field editor associated with the text field in
the awakeFromNib of your controller and configure it. The code could be
something like:
=====
-(void)awakeFromNib
{
[mTextField setSelectable:YES];
[mTextField setDelegate:self];
[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];
}
=====


Hope this helps.

Regards
Shripada





I'd like to pre-place some text into an NSTextField, and then give it
focus (make it firstResponder) and immediately allow the user type in
additional text, concatenating it.

Unfortunately, when I make the field firstResponder, my pre-placed
text is selected, and when the user starts typing, it gets
overwritten.  Very annoying.

Does anyone know how to deselect text in an NSTextField?

NSTextField has a selectText:(id)sender method but no deselectText:
method.

I've tried sending -setStringValue:, -makeFirstResponder: and -
endEditingFor: in various different orders and combinations, but
nothing works.

Thanks,

Jerry Krinock

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: Jerry Krinock <email@hidden>
  • Prev by Date: Re: Opacity of Menus
  • Next by Date: Re: NSTextField: How to DEselect text?
  • Previous by thread: Re: NSTextField: How to DEselect text?
  • Next by thread: Re: NSTextField: How to DEselect text?
  • Index(es):
    • Date
    • Thread