• 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: Programmatically place cursor within NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programmatically place cursor within NSTextField


  • Subject: Re: Programmatically place cursor within NSTextField
  • From: chaitanya pandit <email@hidden>
  • Date: Wed, 13 Aug 2008 12:07:06 -0400


Hi,
You first have to compute the character index where you need to place the cursor, then create a range with zero length and location = character index,
Then get the editor (NSText object) for the text field, you can get one by calling NSWindow's
"- (NSText *)fieldEditor:(BOOL)createWhenNeededforObject:(id)anObject"
and passing your NSTextField object as anObject
Then eventually call "- (void)setSelectedRange:(NSRange)aRange" on the text object by passing the range you computed in the first step.


Hope this helps,
Chaitanya

On 13-Aug-08, at 7:02 AM, email@hidden wrote:

How can I programmatically position the cursor to an arbitrary position with a NSTextField?

For example, placing a cursor within the parentheses '('...')' of a phone number?

Regards,

Ric.
_______________________________________________

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

_______________________________________________

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


References: 
 >Programmatically place cursor within NSTextField (From: email@hidden)

  • Prev by Date: Why won't Gmail cooperate with authentication delegate methods? (Gmail RSS feeds do.)
  • Next by Date: Re: Subclassing NSTextView
  • Previous by thread: Programmatically place cursor within NSTextField
  • Next by thread: Re: Programmatically place cursor within NSTextField
  • Index(es):
    • Date
    • Thread