Re: Return and Enter don't "behave" in Text Field (Newb)
Re: Return and Enter don't "behave" in Text Field (Newb)
- Subject: Re: Return and Enter don't "behave" in Text Field (Newb)
- From: Aki Inoue <email@hidden>
- Date: Mon, 20 Oct 2008 16:09:20 -0700
On 2008/10/20, at 13:46, John Velman wrote:
Thanks, Aki, this helps clear some things up. However, two questions:
1) What does "possibly" depend on? Surely its not random :-)
Well, I admit "possibly" is probably too vague to be useful 8-).
The behavior is controlled by the NSTextMovement key in the
NSTextDidEndEditing notification.
If it's either NSTabTextMovement or NSBackTabTextMovement AND there is
a valid key view in the corresponding direction, the focus moves to
the next/previous key view. Otherwise, it just invokes -selectText:
to self.
2) So, I gather that I should be able to get the behaviour I want by
putting in my delegate something like
[[aTextView window] selectNextKeyView:[aTextView nextResponder]];
I tried this and it doesn't work. Could be I'm sending the message
to the
wrong object?
You should be able to do it inside
control:textView:doCommandBySelector:.
Need to return YES to indicate that the text field should not handle
the key event.
Aki
Thanks,
John Velman
On Mon, Oct 20, 2008 at 12:29:00PM -0700, Aki Inoue wrote:
John,
"End editing" doesn't necessarily mean losing focus in terms of
behavior
visually users can see.
In this case, NSTextField does end editing, but calls -selectAll:
immediately afterwards to keep the focus.
Discussion Field editors interpret Tab, Shift-Tab, and Return
(Enter) as
cues to end editing and possibly to change the first responder.
Notice "possibly" in the sentence. Return (Enter) does not change
the
first responder.
Aki
On 2008/10/20, at 11:49, John Velman wrote:
This must have a simple answer, but I can't find it.
I have several text fields in in a window. I've set the
nextKeyView as I
like it, and tabbing works. But pressing enter or return
highlights the
whole cell as selected, rather than ending editing of that cell as I
believe it should.
I used caveman debugging in the following way:
I made files owner the delegate for the text field in one of the
boxes.
In
Files Owner, I put in the delegate
- (BOOL)control:(NSControl *)control
textView:(NSTextView *)aTextView
doCommandBySelector:(SEL)aSelector
Here I test for which selector (either return or enter gives
"insertNewline:"). I also test "aTextView" with "isFieldEditor",
which
returns 1 (YES);
Now the documentation says of isFieldEditor:
<quote>
Return Value YES if the text views sharing the receiver’s
layout manager
behave as field editors, NO otherwise.
Discussion Field editors interpret Tab, Shift-Tab, and Return
(Enter) as
cues to end editing and possibly to change the first responder.
Non-field
editors instead accept these characters as text input. See Text
Fields,
Text Views, and the Field Editor for more information on field
editors. By
default, text views don’t behave as field editors.
</quote>
So where can I look to find out why my field editor is not
behaving as a
field editor?
Thanks,
John Velman
_______________________________________________
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