Re: Programmatically place cursor within NSTextField
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