Re: Tons of fun w/NSComboBox
Re: Tons of fun w/NSComboBox
- Subject: Re: Tons of fun w/NSComboBox
- From: Mike Brinkman <email@hidden>
- Date: Thu, 14 Aug 2003 08:48:23 -0400
Here is what I tried:
#import <AppKit/AppKit.h>
@interface BetterComboBoxCell : NSComboBoxCell {
}
@end
#import "BetterComboBoxCell.h"
@implementation BetterComboBoxCell
- (NSString *)completedString:(NSString *)substring
{
return [super completedString:[substring capitalizedString]];
}
- (void)dealloc
{
[super dealloc];
}
@end
And then in my Document.h file declare:
BetterComboBoxCell *myComboBoxCell;
Then in my Document.m file declare:
- (void)awakeFromNib
{
...
[myComboBox setCell:myComboBoxCell];
...
}
It compiles, but when I run it, my combo boxes disappear. What am I doing
wrong?
On 8/13/03 3:52 PM, "Jonathan E. Jackel" <email@hidden> wrote:
>
>
> 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.