Re: Problem on clearing points and paths on a NSView
Re: Problem on clearing points and paths on a NSView
- Subject: Re: Problem on clearing points and paths on a NSView
- From: "Ken Ferry" <email@hidden>
- Date: Tue, 22 Jul 2008 23:04:10 -0700
On Tue, Jul 22, 2008 at 9:06 PM, Jens Alfke <email@hidden> wrote:
>
> As Graham pointed out, the reason your shapes don't get erased is that you
> don't erase them. Your -drawRect method needs to begin by clearing the
> passed-in NSRect to the background color, otherwise you may be leaving
> behind the old contents of the view.
Er, perhaps I'm missing something relevant (and I haven't really
reviewed the original poster's code), but this is not in general true.
When a region of a window needs to be redrawn, Cocoa clears the dirty
region of the window, then draws each view that overlaps that region
in turn, bottom to top. As an optimization, if a view covers the
region and returns YES to -[NSView isOpaque], then Cocoa does not
bother to clear the window or draw anything under that view, since
that view has pledged to completely cover the drawing anyway.
But unless you've pledged that you're opaque by returning YES from
isOpaque, you should not need to explicitly fill your bounds in
drawRect:.
-Ken
Cocoa Frameworks
_______________________________________________
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