Re: lockFocus error
Re: lockFocus error
- Subject: Re: lockFocus error
- From: Graham Cox <email@hidden>
- Date: Tue, 21 Oct 2008 11:52:31 +1100
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:
This email sent to email@hidden