Re: Custom control class question
Re: Custom control class question
- Subject: Re: Custom control class question
- From: Shaun Wexler <email@hidden>
- Date: Thu, 12 Feb 2004 03:57:39 -0800
On Feb 11, 2004, at 7:24 PM, Jim O'Connor wrote:
I need a custom slider class to be invoked by a nib, so I worked my
way down
in the IB classes tab to the NSSlider class and added a subclass,
FavoriteSlider.
Then in my header file is have:
@interface FavoriteSlider : NSSlider
@end
@interface FavoriteSliderCell : NSSliderCell
@end
In my .mm file I have:
@implementation FavoriteSlider
+ (Class) cellClass
{
return [FavoriteSliderClass class];
}
@end
return [FavoriteSliderCell class];
@implementation FavoriteSliderCell
- (void)drawBarInside:(NSRect)aRect flipped:(BOOL)flipped
{
// do some stuff
}
@end
My nib is loaded and the cellClass method is never called.
Am I missing something? I've been away from cocoa for a while, and I
wasn't
that proficient at it when I was using it more frequently.
Interface Builder stores an archived copy (of the actual instance you
see when creating your layouts) into the nib file, thus archiving the
default cell along with it. There are a few ways to handle this, but
the easiest (apart from fixing the above error in your code) would be
to tweak your FavoriteSlider class to replace the cell with the proper
cellClass upon instantiation.
In FavoriteSlider -initWithCoder:, first call super's implementation,
then if ![cell isKindOfClass:[FavoriteSliderCell class]], create a new
cell using the archived properties of the instance's cell, and then
[self setCell:favoriteCell];
--
Shaun Wexler
MacFOH
http://www.macfoh.com
_______________________________________________
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.