Re: Newbie - which NSTextField is the cursor in?
Re: Newbie - which NSTextField is the cursor in?
- Subject: Re: Newbie - which NSTextField is the cursor in?
- From: Douglas Davidson <email@hidden>
- Date: Mon, 18 Mar 2002 10:45:05 -0800
On Monday, March 18, 2002, at 10:11 AM, email@hidden wrote:
[window firstResponder] should be correct in theory. However, I
think it might return the field editor for the textfield, not the
textfield itself. I'm not sure offhand how to get from the field
editor back to the original textfield.
You know whether there is a text field edited currently by checking if
the first responder is a NSTextView and responds YES to isFieldEditor.
If so, its delegate is the currently edited NSTextField.
Interesting. Sounds generally reliable, although the -isFieldEditor
method sounds like it doesn't actually have anything directly to do
with whether the NSText object is being used as a field editor; its
direct semantic meaning has to do with the way tab, shift-tab, and
enter behave, and non-field-editor NSText objects may still return YES
for -isFieldEditor, as I read the doc. Furthermore, I can't find
anything in the doc about the field editor's delegate; is this a
documented behavior that one may rely on, or does it just happen to be
the case in the current implementation?
If one needs to get from the field editor back to the editing
textfield, this sounds like the way, as the APIs currently stand, but
it would be nice for there to be a clearer way, or at least clearer
doc. In any case, I don't think it is necessary to solve the problem
the original poster had, so given these concerns, perhaps other
solutions might be better...
It is usually the case that a control acts as the field editor's
delegate while it is editing. However, this is up to the control, and
controls can in principle make different choices. One thing you should
be able to rely on, though, is the -[NSControl currentEditor] method.
If this returns a non-nil value, then it should be the case that the the
control is editing, and that the return value is the field editor.
Douglas Davidson
_______________________________________________
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.