Re: Text scrolling with Finder-like label editing. Will a raw field editor (NSTextView) do this, or should I use an NSTextField or NSTextFieldCell?
Re: Text scrolling with Finder-like label editing. Will a raw field editor (NSTextView) do this, or should I use an NSTextField or NSTextFieldCell?
- Subject: Re: Text scrolling with Finder-like label editing. Will a raw field editor (NSTextView) do this, or should I use an NSTextField or NSTextFieldCell?
- From: Eric Gorr <email@hidden>
- Date: Wed, 4 Mar 2009 15:08:03 -0500
On Mar 4, 2009, at 2:37 PM, Luke Evans wrote:
Thanks Eric.
It makes sense, I suppose, that NSTextView wouldn't have an built-in
way to do this - it just acts as a 'sheet' of text over which you
must create a viewport in the form of a scroll view.
Actually, I've _literally_ just bumped into the reference below,
while writing this:
http://developer.apple.com/documentation/Cocoa/Conceptual/TextUILayer/Tasks/TextInScrollView.html
... previously I'd avoided trawling through the text system
documentation - probably because I didn't think I was _really_ doing
anything for which I wanted The Text System per se ;-)
I think I'm going to try programmatically popping the field editor
into an scroll view configured per this note and adding this whole
kit and caboodle to to my view hierarchy, rather than just the
NSTextView. Hopefully all the resizing will work as I need that.
Anyway, I'll report back...
If you succeed, I would be interested.
While I was able to successfully place my own NSTextView into a
NSScrollView and have the text scroll as I typed, I was unable to
accomplish the same when I tried it with the fieldEditor. Perhaps you
will be able to figure out where I went wrong.
But, actually, I ran into another problem involving drawing a focus
ring around the field. You should be aware that a NSTextView
+NSScrollView will not automatically draw a focus ring around
themselves. You will have to do that yourself. Unfortunately, I was
unable to get it to work correctly under different circumstances which
you may or may not run into - assuming you want a focus ring. I didn't
have the time to figure out exactly what was going wrong. My old
thread on this topic was:
http://lists.apple.com/archives/cocoa-dev/2009/Mar/msg00142.html
But, it does not cover the problem I had with it.
So, I ended up dumping my NSTextView entirely and, as you mentioned in
your initial posting, used a NSTextField to do the editing. An
NSTextField will automatically draw a focus ring, seems to know how to
do it the right way, and provides all of the text editing support I
need.
_______________________________________________
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