I posted some source code (NonSelectingTokenField) in response to a StackOverflow question. It avoids the default behavior of selecting all tokens when becoming first responder or ending editing.

The source code is a drop-in NSTokenField subclass, but it’s also a good example of how to change the selected range of any NSTextField subclass. Since there’s no direct method to manipulate the selected range in an NSTextField subclass – other than the brain-dead -selectText: method, which selects all text in the field – this question has come up countless times over the years.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2011 Joshua NozziJoshua Nozzi is a Cocoa developer for hire.Suffusion theme by Sayontan Sinha