RE: Tons of fun w/NSComboBox
RE: Tons of fun w/NSComboBox
- Subject: RE: Tons of fun w/NSComboBox
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Wed, 13 Aug 2003 15:52:06 -0400
>
If I override (NSString *)completedString:(NSString *)substring, does it
>
apply to every NSComboBox on my app, or does it apply only to a particular
>
NSComboBox?
The latter. You should subclass NSComboBoxCell and write your own
implementation of completedString. In awakeFromNib, you should set the cell
of the combo cox to be an instance of your subclass. Your implementation
will work only for instances of your subclass, so it will only work for
combo boxes where you have explicitly set the cell to be your cell.
>
This seems like a lot of work for something pretty trivial.
Loop through the object values. Stop when you hit one whose first n
characters match what the user has typed. If you want the comparison to be
case insensitive, convert them both to lowercase or uppercase first. Return
the matching value if there is one, nil otherwise.
Its even simpler if your list consists of items whose words are all
capitalized. Then you do:
- (NSString *)completedString:(NSString *)substring
{
return [super completedString:[substring capitalizedString]];
}
The same kind of idea could be applied to a list that is totally lowercase
or uppercase.
Doesn't seem like that much work.
Jonathan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.