Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hrishidev

macrumors regular
Original poster
Dec 3, 2007
107
4
I want to autocompletion of NstextField from dropdown list ...... just like the Apple Mail "new Message" does by suggesting the email ids
 

stadidas

macrumors regular
Feb 27, 2006
243
0
Kent, United Kingdom
You will need to change you text field to an instance of NSComboBox. Then, create your NSArray (or of course mutable array) of strings, and send it to the combo box like this:

Code:
[myComboBox addItemsWithObjectValues:listOfStrings];

If you want to sort the list alphabetically, you do it like this:

Code:
[listOfStrings sortUsingSelector:@selector(caseInsensitiveCompare:)];

Obviously do that before using the addItemsWithObjects method above.
To clear the list of completions in a combo box, use this method:

Code:
[myComboBox removeAllItems];

Hope that helps.
 

hrishidev

macrumors regular
Original poster
Dec 3, 2007
107
4
Let me make it clear ... there is 1 nstextfiled where user will type the value ......
as soon as he starts typing , suggestions will appear in dropdowns list ... usr can select any matching suggestion or he will continue typing .. as typing continues .... drop down list will change ..... .
Same like apple Mail as i mentioned earlier ....

Anyways , Thanks for your Help :)
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Use an NSTextView instead which has lots of methods to override (or delegate methods if you don't want a custom subclass) for autocompletion. See the documentation under Text Completion.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.