Re: Drawing onto NSImageView subclass (Newbie)
Re: Drawing onto NSImageView subclass (Newbie)
- Subject: Re: Drawing onto NSImageView subclass (Newbie)
- From: Alan Cook <email@hidden>
- Date: Mon, 9 Feb 2004 16:53:50 -0800 (PST)
>
Show us your code for mouseDown: and drawRect:
Here it is. Some of the code can be moved around without any effect
like the [path fill] in drawRect:, but since that is actually drawing
it, it seemed that drawRect: would be the acceptable place to put it.
I also included the code for addPoint: (poorly named).
-(void)mouseDown:(NSEvent *)event
{
NSPoint eventLocation = [event locationInWindow];
center = [self convertPoint:eventLocation fromView:nil];
[self setNeedsDisplay:YES];
}
-(void)drawRect:(NSRect)rect
{
[super drawRect:rect];
[self addPoint:center];
[path fill];
}
-(void)addPoint:(NSPoint)aPoint
{
NSLog(@"Adding point at: %@", NSStringFromPoint(aPoint));
NSRect dotRect;
dotRect.origin.x = aPoint.x - 5.0;
dotRect.origin.y = aPoint.y - 5.0;
dotRect.size.width = 10.0;
dotRect.size.height = 10.0;
[[NSColor redColor] set];
path = [NSBezierPath bezierPathWithOvalInRect:dotRect];
}
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.