Re: A more attractive NSSlider?
Re: A more attractive NSSlider?
- Subject: Re: A more attractive NSSlider?
- From: Julian Cain <email@hidden>
- Date: Thu, 31 Mar 2005 23:08:52 -0500
Hi,
For your NSSlider subclass:
- (void)awakeFromNib {
JSliderCell * aCell = [[[JSliderCell alloc] init] retain];
[aCell setControlSize:NSSmallControlSize];
[self setCell:aCell];
[aCell release];
}
And for the Cell:
static NSImage * _knobOff = nil;
static NSImage * _knobOn = nil;
@implementation LNSliderCell
-(id)init {
self = [super init];
_knobOff = [[NSImage imageNamed:@"knob_cold"] retain];
return self;
}
- (void)drawKnob:(NSRect)knobRect {
NSImage * knob = _knobOn;
[[self controlView] lockFocus];
[knob compositeToPoint:NSMakePoint(knobRect.origin.x,knobRect.origin.y+knobRect.size.height-2) operation:NSCompositeSourceOver];
[[self controlView] unlockFocus];
}
@end
~Julian
On Mar 31, 2005, at 10:50 PM, Glenn Zelniker wrote:
I would like to either customize or subclass NSSlider. In particular, suppose I just want to put a different image behind the knob. I've tried using -setImage methods in NSSlider, NSSliderCell, and NSActionCell, but none of these works. I also began the annoying process of starting from scratch with a subclass of NSView and doing my own -mouseDown, etc. methods, but I soon realized I'd have to be doing a lot of target-action stuff or delegation in order to get my app controller to see values coming from the slider...
To make a long story short, is there a simple way to replace the knob and the background image in an NSSlider? Has anyone implemented a custom NSSlider that lets you set the knob image and the slider background image?
Glenn Zelniker
_______________________________________________
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
_______________________________________________
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