Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSControlTextDidChangeNotification fires only once upon setting delegate



Hello list.

I'm trying to implement a Safari-style address field with completion. I'm using an ImageAndTextCell in an NSMatrix, and trying to leverage the built-in completion by doing the following in my controller code:

* Observe NSControlTextDidChangeNotification notifications from the NSMatrix.
* When the NSControlTextDidChangeNotification arrives, get the field editor for the ImageAndTextCell, and set the field editor's delegate to my controller, so that I get textView:completions:forPartialWordRange:indexOfSelectedItem: delegate calls.
* In textView:completions:forPartialWordRange:indexOfSelectedItem:, I fetch the matching items and return them.


This works as expected, but only the first time, that is, when I type the first character in the field. It fills in the field and selects the part following the keyboard input, and displays the pull-down list with that item selected. However, I do not get NSControlTextDidChangeNotification for subsequent key presses, hence no completion and no pull-down.

If I comment out the body of the NSControlTextDidChangeNotification handler and replace it with an NSLog, I see it is called as expected for all characters. Setting the delegate seems to be enough to cause the problem.

Am I doing something wrong in my delegate that keeps subsequent notifications from firing? I have tried google searches and read the NSTextView class documentation, and I'm stuck.

Is this the wrong approach? Any suggestions are welcome.

Thank you.

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.