Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lockFocus error




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@hidden)

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/email@hidden

This email sent to email@hidden
References: 
 >lockFocus error (From: DKJ <email@hidden>)
 >Re: lockFocus error (From: Nick Zitzmann <email@hidden>)
 >Re: lockFocus error (From: DKJ <email@hidden>)
 >Re: lockFocus error (From: Nick Zitzmann <email@hidden>)
 >Re: lockFocus error (From: DKJ <email@hidden>)
 >Re: lockFocus error (From: Graham Cox <email@hidden>)
 >Re: lockFocus error (From: DKJ <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.