• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTextField in NSCollectionView aborts editing without notice, solved
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTextField in NSCollectionView aborts editing without notice, solved


  • Subject: NSTextField in NSCollectionView aborts editing without notice, solved
  • From: David Carlisle <email@hidden>
  • Date: Sat, 24 May 2008 21:11:49 -0600

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 (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


  • Prev by Date: Re: Handling keyDown events results in beeping from a NSView subclass...
  • Next by Date: Re: Halting a cocoa application?
  • Previous by thread: Re: Handling keyDown events results in beeping from a NSView subclass...
  • Next by thread: to launch safari with an URL
  • Index(es):
    • Date
    • Thread