Re: Problem on drawing custom scroller.
Re: Problem on drawing custom scroller.
- Subject: Re: Problem on drawing custom scroller.
- From: Sumin Kim <email@hidden>
- Date: Mon, 15 Jun 2009 23:23:29 +0900
Dear Lee,
Thanks again on your advice. I tried as you told, and now I understood what you meant.
Best regards,
On Mon, Jun 15, 2009 at 11:41 AM, Andy Lee
<email@hidden> wrote:
On Jun 14, 2009, at 9:03 PM, Sumin Kim wrote:
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.
Someone may have to correct my explanation, but I believe this is because NSBezierPath draws lines exactly on the coordinates that you give it, which means half the line lies outside the rectangle and half lies inside. Notice that if you use NSFrameRect(knobRect) instead of [knobPath stroke], the problem goes away. This is because NSFrameRect() draws the line just inside the rectangle you give it.
@implementation BSScroller
- (void)drawKnob {
NSLog(@"drawKnob ///// ");
NSRect knobRect = [self rectForPart:NSScrollerKnob];
If you want to stick with NSBezierPath, I see that replacing the line above with
NSRect knobRect = NSInsetRect([self rectForPart:NSScrollerKnob], 0.5, 0.5);
also works, though I don't know if that's the "right" way to do it.
There's probably a more precise explanation in the Cocoa Drawing Guide, but I'm too lazy to look for it:
<http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaDrawingGuide/Introduction/Introduction.html>
--Andy
_______________________________________________
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