Re: subclass of NSSlider won't call action method
Re: subclass of NSSlider won't call action method
- Subject: Re: subclass of NSSlider won't call action method
- From: "Timothy J. Wood" <email@hidden>
- Date: Wed, 29 Jun 2005 20:09:16 -0700
On Jun 29, 2005, at 7:16 PM, Chris Stephens wrote:
If I then change the setCell: message to be EluSliderCell I get the
same (broken) behaviour - it looks right and slides fine but won't
call the action. If I then change the method that calls setCell: to
be init instead of awakeFromNib it goes back to working again but
with no appearance change..
Did you try overriding the NSControl method +cellClass so that the
cell will get created for you automatically? I don't recall if you
have to be using a palette for this to work from a nib.
At any rate:
------
@implementation EluSlider
- (void)awakeFromNib {
EluSliderCell *aCell = [[[EluSliderCell alloc] init] retain];
[aCell setControlSize:NSSmallControlSize];
//[aCell setAction:@selector(slider:)]; <-- tried this
[self setCell:aCell];
[aCell release];
[self setMinValue:(float)0];
[self setMaxValue:(float)127];
[self setDoubleValue:64];
//[self setAction:@selector(slider:)]; <-- tried this
}
@end
------
Try adding:
NSCell *oldCell = [self cell];
[aCell setAction:[oldCell action]];
[aCell setTarget:[oldCell target]];
Note that NSControl itself doesn't have a target/action ivar
pair. These are NSActionCell, the superclass of NSSliderCell. So,
when you replace the cell, you are unhooking the target of the slider.
And, there are many other settings on NSSliderCell that this
doesn't copy across -- thus my suggestion to try to get the nib
loading path to create your cell class if at all possible!
-tim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden