I have an NSTextField in an NSCollectionView. If I type in a change to the NSTextField, then without hitting tab or clicking elsewhere in the NSCollectionView I click on a popup menu in the window, the NSTextField aborts the edit and loses the information without any kind of notice being given to the NSTextField.

I solved the problem by subclassing NSTextFieldCell and overriding the method endEditing, passing it up to the superclass after first sending an emergency message to the window controller, along with a copy of the NSTextField, indicating it needs to grab the edited string out of the NSTextField because the information is about to be lost.

I tried monitoring resignsFirstResponder. I can then click on the NSTextFields in the NSCollectionView and get resignsFirstResponder messages as expected. If I click on an NSTextField and then hit a key to begin an edit, the sequence of messages is as follows:

NSTextField gets the message:
textShouldBeginEditing

The NSTextField delegate, which is an NSCollectionViewItem, gets the message:
control:textShouldBeginEditing

NSTextField gets the message:
textDidBeginEditing

The NSTextField delegate gets the message:
control:textDidBeginEditing

After I type in some text, if I were to click on the popup as described, neither NSTextField nor its delegate gets any of the text did/should end editing messages which correspond with the above messages. FWIW, if rather than clicking on the popup menu I click on another text field, the NSTextField gets both of the textShouldEndEditing messages, but not any textDidEndEditing messages. After those messages, it gets the expected resignsFirstResponder message.

If after I click on the popup menu I click on another NSTextField, I do get a resignsFirstResponder message from an NSTextField, but by that time the information in the field I had edited has already been lost.

So is this a bug? Is it a feature? Am I missing something? Has someone already found an easier way of dealing with this? If someone else is already wondering about this problem, then this is the way I solved it.

DC
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to