Re: NSTextField: How to DEselect text?
Re: NSTextField: How to DEselect text?
- Subject: Re: NSTextField: How to DEselect text?
- From: "Clark Cox" <email@hidden>
- Date: Fri, 21 Dec 2007 12:38:09 -0500
On Dec 21, 2007 1:31 AM, Jerry Krinock <email@hidden> wrote:
>
> 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.
No, the selected range and the insertion point are the same thing. If
it has zero length, it shows up as a blinking vertical line, and if it
doesn't, then it appears as a highlighted range of text.
--
Clark S. Cox III
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