NSTextView/Field to relinquish firstResponder after return key
NSTextView/Field to relinquish firstResponder after return key
- Subject: NSTextView/Field to relinquish firstResponder after return key
- From: Russ <email@hidden>
- Date: Thu, 23 Sep 2010 08:42:20 -0700 (PDT)
The desired behavior is that when the user hits the return key after editing the
contents of a NSTextView (replaced by NSTextField during editing), the
firstResponder should be cleared and set to the overall window, with the text
field no longer editing. Instead, the text field becomes fully selected and
remains editing.
The key issue seems to revolve around NSTextField's textDidEndEditing, which has
the following stated behavior:
"If the user ended editing by pressing Return, this method tries to send the
receiver’s action to its target; if unsuccessful, it sends performKeyEquivalent:
to its NSView (for example, to handle the default button on a panel); if that
also fails, the receiver simply selects its text."
I have a bunch of breakpoints set throughout things. I can see the following
happening:
1. NSTextView's insertNewline calling its _giveUpFirstResponder which then calls
the window's makeFirstResponder to set the first responder to the window itself
(ie removing firstResponder from the field)
2. The NSTextView's action routine gets called, via NSTextField's
textDidEndEditing, still from within NSTextView's _giveUpFirstResponder: from
insertNewLine:
3. The window's makeFirstResponder gets called again, re-setting the
firstResponder back to the same field, from within NSTextField selectText: from
within textDidEndEditing:, from within _giveUpFirstResponder: and insertNewLine:
Since the action routine for the field is definitely getting called---it's my
routine and I've got a breakpoint sitting right in the middle---you'd think that
would qualify as successful. There's nothing else an action routine has to do to
indicate that it is successful, right? They can't/don't have any return values.
I don't understand why the fallback is being performed ("simply selects its
text") when the action has definitely run.
And my action routine has limited workaround capability---it can not override
the firstResponder status itself, since textDidEndEditing will re-set
firstResponder subsequently (ie step #3).
It seems like textDidEndEditing is doing some
wrong/inexplicable/inconvenient/etc. Ideas?
_______________________________________________
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