 |
 |
Cocoa: auto completing a string in a text field
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
I was wondering how I can make it so that an NSTextField will autocomplete a string as the user begins typing in it? I would really like the behavior of the TO: textfield in Mail.app which has a menu drop down filled with options of strings the user can select. I have found NSComboBox, but that isn't what I want. Any suggestions?
The strings which should match up to the one the user is typing will be stored in an NSArray.
TIA
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
Implement -controlTextDidChange: in your TextField's delegate. There you can do whatever array comparisons, etc. you need to find matches. Apple isn't really doing any custom-control magic to make a list of matches show up -- they just put up a borderless window containing a TableView, and you can do the same.
Oh, and if you need some help with the string-matching logic, see OATypeAheadSelectionHelper in the open-source OmniAppKit framework.
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Oct 2001
Location: London
Status:
Offline
|
|
Nice tip Rickster - I always wondered how they did that.
plus I learned a lot about windows by doing that.
I found that sending orderOut: to a window attached to another window hides both - is that supposed to happen?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
Ok, I have one last question on this issue, I now have it so that a little window appears along a table row, but when it does so, the scrollbar on the parent window becomes greyed out. How do you have it so that the child window, which in my case they type into because it has an NSTextView in it, is the "key" window, while the other parent window remains "key" also. Do you know what I am saying? (I don't know if use of "key" is correct or not.)
I want to do what Apple did with Address Book where they have little windows "appear" as you are editing, but the main window doesn't grey out or anything.
Anyone know how to do this?
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Make the window a borderless utility panel rather than a normal window?
I'm just guessing here, but I don't think it could hurt to try...
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
Good thinking, but I just tried it and still no luck.
Surely someone knows how to do it? Rickster?
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status:
Offline
|
|
The things in Address book aren't windows. They're just a custom border around a text field.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
Ok. But in Mail they have the borderless window appear below the To: field without the scrollbar on the message window turning grey. Do you know how they do that?
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Aug 2002
Location: Oxford, England
Status:
Offline
|
|
Originally posted by Rickster:
The things in Address book aren't windows. They're just a custom border around a text field.
How would you do that then?
|
|
Luke
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Another wild guess...maybe a borderless panel, with becomesKeyOnlyIfNeeded set to YES?
*shrug*
I'd like to know, too...
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
Originally posted by Wevah:
Another wild guess...maybe a borderless panel, with becomesKeyOnlyIfNeeded set to YES?
Still no luck...darn.
|
|
|
| |
|
|
|
 |
|
 |
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Would just putting up an NSView not work?
|
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
I don't know. Can I still get the drop shadow and make it so that the view is "attached" to the "parent window"?
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Hmmm...I keep hearing about layered views doing odd things...
|
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|