• 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: drawKnob in NSSliderCell subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawKnob in NSSliderCell subclass


  • Subject: Re: drawKnob in NSSliderCell subclass
  • From: Lon Giese <email@hidden>
  • Date: Fri, 19 May 2006 19:26:45 -0700


The knob is getting clipped by the sliders frame... you have a horizontal slider from the looks of things
When the knob travels to each end it is so thick it gets clipped at each end of the slider by the frame.
making the frame wider doesn't help cause the sliding slot is made equally longer...


it looks like this should work but I tried it and it does not... no change. The docs say the method was deprecated but there is no replacement method., probably cause it does not work. You can see on a normal slider the knob stops at the ends of the frame cause the slider takes into account the thickness of the knob...
int knobWidth = [[NSImage imageNamed:@"square.tif"] size].width;
[self setKnobThickness:knobWidth];
maybe malcolm knows why this method was deprecated and what to do in place of it


Im not really an expert on this stuff, but you might try creating a seperate view to draw the knob in that lays over the top of the sliders view, make the knob's view wider than the slider's view by the width of the knob and offset by half the width of the knob. you'll have to play with the math a little to get the rects right, but I have a feeling that might work... It will be pretty complicated, but you'll figure it out...

On May 19, 2006, at 6:18 PM, Christoph Teschner wrote:

-(id)init {
	self = [super init];
	knobImage = [[NSImage imageNamed:@"square.tif" ]retain];
	return self;
}

- (void)drawKnob:(NSRect)knobRect{
[[self controlView] lockFocus];
[knobImage compositeToPoint:NSMakePoint(knobRect.origin.x ,knobRect.origin.y+knobRect.size.height) operation:NSCompositeSourceOver];
[[self controlView] unlockFocus];
}


- (NSRect)knobRectFlipped:(BOOL)flipped{
	NSRect myRect = [super knobRectFlipped:flipped];
	myRect.origin.y -= ([knobImage size].height - myRect.size.height) / 2;
	myRect.origin.x -= ([knobImage size].width - myRect.size.width) / 2;
	myRect.size = [knobImage size];
	return myRect;
}
_______________________________________________
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


  • Follow-Ups:
    • Re: drawKnob in NSSliderCell subclass
      • From: Lon Giese <email@hidden>
References: 
 >Re: drawKnob in NSSliderCell subclass (From: "Christoph Teschner" <email@hidden>)

  • Prev by Date: IBPalette Custom Container view
  • Next by Date: Re: drawKnob in NSSliderCell subclass
  • Previous by thread: Re: drawKnob in NSSliderCell subclass
  • Next by thread: Re: drawKnob in NSSliderCell subclass
  • Index(es):
    • Date
    • Thread