Re: Stop edit session with a NSTextField
Re: Stop edit session with a NSTextField
- Subject: Re: Stop edit session with a NSTextField
- From: Eric Gorr <email@hidden>
- Date: Wed, 25 Feb 2009 13:09:59 -0500
On Feb 25, 2009, at 12:20 PM, Eric Gorr wrote:
On Feb 25, 2009, at 11:14 AM, Andy Lee wrote:
On Feb 24, 2009, at 6:08 PM, Eric Gorr wrote:
*** [[[self view] window] makeFirstResponder:[self view]];
Pressing return will allow the editing session to end, but
pressing the tab key will not
Looks like controlTextDidEndEditing: is too deep within the text
field's event handling to muck with the first responder. Delaying
the call to makeFirstResponder: seems to work:
[[[self view] window]
performSelector:@selector(makeFirstResponder:) withObject:nil
afterDelay:0.0];
(Note this passes nil to makeFirstResponder: rather than the
view.) I don't know if this is foolproof -- for example, I haven't
tried it with different accessibility settings. And note that if
you normally have a tab loop this will defeat the tab loop.
With only a slight modification, this worked.
Since I needed to do some more work after the first responder
changed, I ended up doing:
[collectionView performSelector:@selector(labelStoppedEditing:)
withObject:[self view] afterDelay:0.0];
The collectionView is my custom table that holds all of my items. I
simply added a selector called labelStoppedEditing to it and passed
as the object the item with the label that just stopped editing
([self view]).
I don't have to worry about a tab loop...at least at this point.
But, this might change, so I am hoping that there still might be
another solution that would support a tab loop and would not have
any of the accessibility problems you were concerned about. As my
collectionView can accept first responder status, I find it odd that
tabbing out of the NSTextView does not cycle around to it. After I
start the edit session, I printed out my responder chain:
2009-02-25 12:01:55.217 NNAOutlineCollection-VB[62103:813] first
responder: <NSTextView: 0x3e9aa0>
2009-02-25 12:02:08.002 NNAOutlineCollection-VB[62103:813] next
responder: <_NSKeyboardFocusClipView: 0x3f3000>
2009-02-25 12:02:16.629 NNAOutlineCollection-VB[62103:813] next
responder: <ResourceItemLabel: 0x348170>
2009-02-25 12:02:19.549 NNAOutlineCollection-VB[62103:813] next
responder: <ResourceItem: 0x356690>
2009-02-25 12:02:21.798 NNAOutlineCollection-VB[62103:813] next
responder: <OutlineCollectionView: 0x331e10>
2009-02-25 12:02:27.142 NNAOutlineCollection-VB[62103:813] next
responder: <NSClipView: 0x326d50>
2009-02-25 12:02:29.197 NNAOutlineCollection-VB[62103:813] next
responder: <OutlineCollectionScroller: 0x325650>
2009-02-25 12:02:30.484 NNAOutlineCollection-VB[62103:813] next
responder: <NSView: 0x30f420>
2009-02-25 12:02:31.758 NNAOutlineCollection-VB[62103:813] next
responder: <NSWindow: 0x3347d0>
2009-02-25 12:02:32.938 NNAOutlineCollection-VB[62103:813] next
responder: (null)
After I receive controlTextDidEndEditing:, the responder chain looks
like:
2009-02-25 12:14:33.284 NNAOutlineCollection-VB[62596:813] first
responder: <NSWindow: 0x3345f0>
2009-02-25 12:14:36.413 NNAOutlineCollection-VB[62596:813] next
responder: (null)
which seems very odd. It doesn't look like a tab loop is going to
work if I did have one. I removed the call to
performSelector:withObject:afterDelay: and tried sticking an
editable NSTextField on my window just to see if I could tab to it
and I could not.
So, now what seems to be working well is:
1. Make the NSTextField not selectable or editable by default
2. When the user clicks on the NSTextField, change it to be selectable
and editable
3. When controlTextDidEndEditing: is called, change the field back to
not being selectable or editable
With this there isn't a need try to manually change the first
responder, remove the NSTextView from the window, or do a delayed
performSelector call.
There still may be something funky with the tab loop...I am still
looking into it.
_______________________________________________
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