NSSliderCell Drawing Issue
NSSliderCell Drawing Issue
- Subject: NSSliderCell Drawing Issue
- From: David Borland <email@hidden>
- Date: Fri, 7 Oct 2005 17:19:52 -0700
I'm trying to create a control that is a ruler that has a transparent
control over it that shows what part of the ruler is actively being
displayed in a view.
I've tried to create this controller by subclassing both NSSlider and
NSScroller, and I can't get either of them to work. The problem in
both cases appears to be because I want the control to be larger then
a NSRegularControlSize control.
For the NSSlider attempt, I have these two methods in the
RulerSliderCell class:
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
[self drawRuler:cellFrame];
cellFrame.origin.y += cellFrame.size.height - 20;
cellFrame.size.height = 20;
[super drawWithFrame:cellFrame inView:controlView];
} /* drawWithFrame:inView: */
This draws my ruler and the slider grove at the bottom of the ruler.
-(void)drawKnob:(NSRect )knobRect
{
[[NSColor redColor] set];
[NSBezierPath fillRect:knobRect];
float height = knobRect.origin.y;
knobRect.origin.y = 0;
knobRect.size.height = height;
[NSBezierPath strokeRect:knobRect];
}
And this draws a red rectangle in the grove, and a hollow rectangle
over the ruler when I start up the test application. The problem is
that when I move the knob, the the rectangle in the grove moves, but
the hollow rectangle stays put. It only gets drawn when resize the
view or click out of the app.
In my NSScroller attempt, I have similar methods, and similar
results. The extra thing that goes wrong with the NSScroller
subclass is that it only responds to clicks in the area of that
control that is NSRegularControlSize.
Any clues on how to fix either of my problems?
David Borland
Electrical Geodesics, Inc
_______________________________________________
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