• 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: Custom control class question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom control class question


  • Subject: Re: Custom control class question
  • From: Vince DeMarco <email@hidden>
  • Date: Fri, 13 Feb 2004 09:01:34 -0800

On Feb 12, 2004, at 7:49 PM, Jim O'Connor wrote:

Thanks Shaun,

Got it handled now.


Actually the easiest thing to do is instead of making a custom slider in IB make a matrix of sliders in IB, then make the matrix only have 1 item in it. Then in IB set the class of the 1 cell to your FavoriteSliderCell instead.

This is the easiest thing to do. YOu don't have to write any special code for this to work.


vince


Jim

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];
_______________________________________________
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.
_______________________________________________
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.

References: 
 >Re: Custom control class question (From: "Jim O'Connor" <email@hidden>)

  • Prev by Date: Re: XCode const warnings
  • Next by Date: DO optimisation questions
  • Previous by thread: Re: Custom control class question
  • Next by thread: Grayscale NSImage?
  • Index(es):
    • Date
    • Thread