On 21 Oct 2008, at 10:48 am, DKJ wrote:

On 20 Oct, 2008, at 16:32, Graham Cox wrote:
What would you expect it to do?


Suppose I wanted it to draw lines in response to user input. Would I put NSBezierPath methods in drawRect: and expose the relevant properties in the subclass?


To draw lines, you can use NSBezierPath as a storage container in your view subclass. You need to:

1. Override -mouseDown: and -mouseDragged: to respond to the mouse
2. Accumulate lines in the NSBezierPath using its -lineToPoint: method for each new mouse point. 3. Mark the view for update using -setNeedsDisplay: or - setNeedsDisplayInRect:
4. Draw the path in -drawRect:

The NSBezierPath object would be owned by your view.

Depending on what you want, you could either clear the path using - removeAllPoints on the mouseDown, or maybe create a new path and add it to a list.

hth,

Graham
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to