Problem on drawing custom scroller.
Problem on drawing custom scroller.
- Subject: Problem on drawing custom scroller.
- From: Sumin Kim <email@hidden>
- Date: Mon, 15 Jun 2009 10:03:37 +0900
Hi, all.
I am new to cocoa. I tried to find out similar topics but couldn't.
I am drawing my own Scroller for my Application. I created a class that inherits NSScroller and implemented several methods to draw custom parts for the class. It seems work fine except only one thing.
When I grab and move the knob in my custom scroller, it leaves its track over the knob slot. So, after I moved the knob several times, the knob slot show several horizontal lines-tracks of the knob- over it. But strangely, when I use arrow keys to move the knob, it just works fine.
Can anybody tell me the clue for solving the problem?
Please refer my implementation of custom scroller class below;
@implementation BSScroller
- (void)drawKnob {
NSLog(@"drawKnob ///// ");
NSRect knobRect = [self rectForPart:NSScrollerKnob];
[[NSColor redColor] setStroke];
[[NSColor blackColor] setFill];
NSBezierPath *knobPath = [NSBezierPath bezierPathWithRoundedRect:knobRect xRadius:2.0 yRadius:2.0];
[knobPath fill];
[knobPath stroke];
}
- (void)drawKnobSlotInRect:(NSRect)slotRect highlight:(BOOL)flag{
NSLog(@"drawKnobSlotInRect ///// ");
[[NSColor whiteColor] setStroke];
[[NSColor blackColor] setFill];
NSBezierPath *knobPath = [NSBezierPath bezierPathWithRoundedRect:slotRect xRadius:2.0 yRadius:2.0];
[knobPath fill];
[knobPath stroke];
}
- (void)drawArrow:(NSScrollerArrow)arrow highlightPart:(BOOL)flag {
NSRect arrowRect = [self
rectForPart:NSScrollerIncrementLine];
[[NSColor yellowColor] set];
[NSBezierPath fillRect:arrowRect];
arrowRect.origin.x += 1.0;
arrowRect.size.width -= 2.0;
arrowRect.origin.y += 2.0;
arrowRect.size.height -= 3.0;
[[NSColor blackColor] set];
[NSBezierPath fillRect:arrowRect];
arrowRect = [self
rectForPart:NSScrollerDecrementLine];
[[NSColor yellowColor] set];
[NSBezierPath fillRect:arrowRect];
arrowRect.origin.x += 1.0;
arrowRect.size.width -= 2.0;
arrowRect.origin.y += 1.0;
arrowRect.size.height -= 1.0;
[[NSColor blackColor] set];
[NSBezierPath fillRect:arrowRect];
}
@end
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden