• 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: custom NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: custom NSTextView
      • From: "Parrish Myers" <email@hidden>
References: 
 >custom NSTextView (From: "Parrish Myers" <email@hidden>)

  • Prev by Date: Re: how do I save prefs when the app is Force Quit?
  • Next by Date: Re: how do I save prefs when the app is Force Quit?
  • Previous by thread: custom NSTextView
  • Next by thread: Re: custom NSTextView
  • Index(es):
    • Date
    • Thread