• 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: A more attractive NSSlider?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A more attractive NSSlider?


  • Subject: Re: A more attractive NSSlider?
  • From: Ryan Stevens <email@hidden>
  • Date: Fri, 1 Apr 2005 07:37:06 -0800

And every time this comes up I say..

Your NSSlider subclass may need to override sizeToFit if your images are larger than the size used by its controlSize.

On Mar 31, 2005, at 8:08 PM, Julian Cain wrote:

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

  • Prev by Date: Re: NSToolbar Problem
  • Next by Date: Re: bindings...
  • Previous by thread: Re: NSToolbar Problem
  • Next by thread: Re: More Newbie Trouble with Basic Bindings
  • Index(es):
    • Date
    • Thread