Re: NSTextView vs NSTextField
Re: NSTextView vs NSTextField
- Subject: Re: NSTextView vs NSTextField
- From: Erik Buck <email@hidden>
- Date: Thu, 11 Nov 2010 07:50:31 -0800 (PST)
NSTextField doesn't display or edit text at all. It uses an instance of NSTextView calle dthe "filed editor" to provide all text dispay and editing. So you are right: NSTextFiled cannot do anythingthat NSTextView can't because NSTextField uses NSTextView.
NSTextView is a large and heavy weight object. If you research the text subsystem, you will find multiple classes that collaborate to provide text display and editing. NSTextView is just the tip of the ice burg. It is the user visible "View" part of a huge infrastructure that includes "Model" and "Controller" components. It is a big deal to set-up and tear-down the whole infrastructure each time an NSTextField becomes editable. Therefore, all NSTextFields (Actually NSTextFiledCells) share a single NSTextView, the filed editor, per window.
As for why not set-up the whole text infrastructure for every label and leave it set up...the best answer is that all of this software worked well on 8MB NeXT Cubes, and not instantiating the entire text system for every field is one reason why.
--- On Thu, 11/11/10, Eric Gorr <email@hidden> wrote:
> From: Eric Gorr <email@hidden>
> Subject: NSTextView vs NSTextField
> To: "Cocoa Dev" <email@hidden>
> Date: Thursday, November 11, 2010, 8:45 AM
> It seems to me that NSTextView can do
> everything that NSTextField can and more. For example, on a
> NSTextView, one can use the method setHorizontallyResizable:
> and then call sizeToFit to get it to resize itself
> vertically instead of horizontally.
>
> Is this correct?
>
> If so and if I am programmatically creating one of these
> controls, is there any reason why I would want to use a
> NSTextField?
> (I know that IB uses a NSTextField for Labels, for
> example...is this just a historical artifact?)
>
> If not, what are the key differences between them that
> would cause me to want to use a NSTextField? Would it
> basically come down to whether or not I need more then a
> single line of text or not...NSTextField seems to be
> optimized for single lines of text, but one can still get
> the same behavior out of a NSTextView with a bit more work.
>
> Now, I know that NSTextFieldCell is commonly used as a
> superclass for one's own cell based stuff, but I would
> consider that as separate from the issue of NSTextField vs
> NSTextView.
>
> Thank you.
>
>
>
>
>
> _______________________________________________
>
> 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
>
_______________________________________________
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