• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Tons of fun w/NSComboBox
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • RE: Tons of fun w/NSComboBox
      • From: "Jonathan E. Jackel" <email@hidden>
References: 
 >RE: Tons of fun w/NSComboBox (From: "Jonathan E. Jackel" <email@hidden>)

  • Prev by Date: inLiveResize question
  • Next by Date: Re: Creating new instances of an IB object
  • Previous by thread: RE: Tons of fun w/NSComboBox
  • Next by thread: RE: Tons of fun w/NSComboBox
  • Index(es):
    • Date
    • Thread