Re: custom NSTextView
Re: custom NSTextView
- Subject: Re: custom NSTextView
- From: Andrew Bowman <email@hidden>
- Date: Sun, 14 May 2006 11:23:26 -0700
On May 14, 2006, at 9:39 AM, Parrish Myers wrote:
Hello all,
Just for fun, I thought I would try to implement an IP Address Text
Field
entry. Remember the IP text entry widget in windows... So the
idea is to
have 4 fields separated by '.' and only allow text selection inside
each
field.
From what I understand this is a good reason to subclass
NSTextView and swap
out the FieldEditor for the NTTextField when asked. I'm getting
the hand
of things, but I can't seem to figure out one thing...
Much like the NSDatePicker, I want to modify the text selection
when the
widget reacts to becomeFirstResponder. But is seems that
NSTextFields
select all text when they become First Responder. Can I change
that? The
NSDatePicker does it somehow... does any one know how to change that?
Thanks.
Parrish
You're going to need to grab the field editor and make a
setSelectedRange call with an empty range starting at the end of the
text. After you've obtained the field editor, it's something like this:
[fieldEditor setSelectedRange: NSMakeRange([[self stringValue]
length], 0)];
- Andrew Bowman
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden