Re: What is a Field Editor (and why does it hate me!)
Re: What is a Field Editor (and why does it hate me!)
- Subject: Re: What is a Field Editor (and why does it hate me!)
- From: "Erik M. Buck" <email@hidden>
- Date: Mon, 27 Jan 2003 16:55:57 -0500
As you will find documented and explained in Apple's documentation here:
http://developer.apple.com/cgi-bin/search.pl?&q="field editor"&num=50&lr=l
ang_en&ie=utf8&oe=utf8&restrict=(cocoa)
and at many of the links found with the following simple search:
http://www.google.com/search?as_q=Cocoa+Field+Editor&num=10&hl=en&ie=UTF-8&o
e=UTF-8&btnG=Google+Search&as_epq=&as_oq=&as_eq=&lr=&as_ft=i&as_filetype=&as
_qdr=all&as_occt=any&as_dt=i&as_sitesearch=&safe=images
<Quote>
Using the Window's Field Editor
Each NSWindow has a text object that is shared for light editing tasks. This
object, the window's field editor, is inserted in the view hierarchy when an
object needs to edit some text and removed when the object is finished. The
field editor is used by NSTextFields and other controls, for example, to
edit the text that they display. The fieldEditor:forObject: method returns a
window's field editor, after asking the delegate for a substitute using
windowWillReturnFieldEditor:toObject:. You can override the NSWindow method
in subclasses or provide a delegate to substitute a class of text object
different from the default of NSTextView, thereby customizing text editing
in your application.
) 2002 Apple Computer, Inc. (Last Published October 31, 2002)
<End Quote>
There is a lot of information spread all over Apple's documentation. In
previous versions of the documentation, it was all in the NSWindow class
information as I recall.
Anyway, to expand on the terse quote already provided:
Text formatting, editing, and display are fairly heavyweight operations
requiring lots of variables for configuration etc. Rather than incur the
overhead of a full text suite for every text field or light text display
task such as drawing labels, each window provides a single shared instance
of the NSText or NSTextView for use by all of the controls and other views
within the window. The shared instance of NSText or NSTextView is called the
"field editor" and is accessed via NSWindow's -fieldEditor:forObject:
method. Most text displayed including most probably the window's title
itself is drawn with the aid of the field editor. Controls like NSTextField
and cells like NSTectFieldCell use the field editor for its editing
capabilities as well as its drawing capabilities.
All views including the field editor need to be in the view hierarchy within
a window to work properly. The field editor is added and removed from the
view hierarchy as needed. When text editing begins in any text view
including the field editor, the view becomes the first responder if it is
not already. The text view stays the first responder until editing ends.
Another way to look at it is that forcing a text view to resign its first
responder status also forces it to end the current editing session.
By forcing the window that contains a text view to become first responder,
you are indirectly forcing the field editor to resign first responder status
and to end editing. When the field editor ends editing, it is removed from
the view hierarchy and the view hierarchy is restored to the configuration
it had before the editing started. Your stack trace shows the field editor
being removed. The view being removed is presumably NOT the view you
programmatically created unless you told the window to use your view as the
field editor.
Compare the address of the view you created and the view being removed and
you will probably see that they are different.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.