• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Drawing onto NSImageView subclass (Newbie)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Drawing onto NSImageView subclass (Newbie)
      • From: John Harte <email@hidden>
    • Re: Drawing onto NSImageView subclass (Newbie)
      • From: Andreas Mayer <email@hidden>
    • Re: Drawing onto NSImageView subclass (Newbie)
      • From: Jens Bauer <email@hidden>
  • Prev by Date: Re: Localizable.strings *just stop working*
  • Next by Date: Re: variadic variable argument list in #define
  • Previous by thread: Re: Drawing onto NSImageView subclass (Newbie)
  • Next by thread: Re: Drawing onto NSImageView subclass (Newbie)
  • Index(es):
    • Date
    • Thread