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 12:54:36 +0900
Dear Lee,
Thanks for your reply and advice.
I will check and try as you recommended. In the mean time, I have another question from your mail.
If I do not use NSBezierPath, is there any other option to draw custom arrows and knob? Do you mean using image file?
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