[Q] detecting when a NSTextField begins editing
[Q] detecting when a NSTextField begins editing
- Subject: [Q] detecting when a NSTextField begins editing
- From: Eric Gorr <email@hidden>
- Date: Wed, 4 Feb 2009 12:00:55 -0500
I am familiar with the NSControlTextDidBeginEditingNotification
notification, but this notification is insufficient for my needs
because it is only sent after the user actually changes the text and
not when the user clicks in the field and it actually allowed to
change the text.
The reason this is important is that I have a text field which is part
of an item in a NSCollectionView. I need to allow the user to to click
and edit the text, but I also need the NSCollectionView to be able to
mark the item as selected if the user does so. At the moment, if the
user clicks in the field to edit the text, the NSCollectionView's
selected items are not changed.
One possible solution I am considering, is sending a notification that
my collection view is observing when the user is actually allowed to
change the text. When the NSCollectionView responds to the
notification, it would mark the item as selected.
The question is: Where should the code to send the notification be
placed?
One possible implementation is to subclass the NSTextField and
override the becomeFirstResponder method which I think is only called
when the user is actually allowed to being editing the text. I am
disturbed by the fact that immediately after becomeFirstResponder is
called, resignFirstResponder is called. Although, the fact that
resignFirstResponder is probably not of any concern since there would
be no reason to change the selection.
Any thoughts or comments?
(I'm kinda hoping there is an easier or standard way to do this which
I have missed in the documentation...)
_______________________________________________
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