Re: clearing NSView outside of drawRect:
Re: clearing NSView outside of drawRect:
- Subject: Re: clearing NSView outside of drawRect:
- From: Chinh Nguyen <email@hidden>
- Date: Fri, 12 Sep 2008 10:29:59 -0500
On Sep 11, 2008, at 10:16 PM, Ken Ferry wrote:
If I read this correctly, you're hoping that you can erase some of the
drawing done in your overlay view, just revealing the original drawing
in your complex background view.
You can get the effect you want in layer backed mode (c.f. -[NSView
setWantsLayer:]). Then each view has its own buffer, so your
selection drawing doesn't wipe out the background drawing, it only
covers it. You don't need to do anything funky with drawing outside
of drawRect:, though. Just call setNeedsDisplay: on the parts of your
selection view that need to be redrawn. This will not cause the
background view to redraw. It's similar to using an overlay window,
just easier.
Thanks for your suggestions. Unfortunately, I can't use [NSView
setWantsLayer:] because I'm trying to support Tiger. I had assumed
that views already had their own backing stores which is why I went
down this route. Your explanation help clear that up and point me in
the right direction.
As for using setNeedsDisplay instead of drawing immediately during
mouseDragged events. My selection is several pixels behind my mouse
as I'm dragging it when I use setNeedsDisplay: (when I tried
setWantsLayer:, it was only a few pixels behind). When I draw
immediately, the selection stays right under the mouse as I drag it.
It's not my background view's drawRect: because I turned it off to
confirm whether it was the source of the lag and it's not my selection
view's drawRect: because my test case is simply drawing a line between
a fixed point and the current location of the mouse. I have not tried
a mouse-tracking loop yet.
-Chinh Nguyen
email@hidden
_______________________________________________
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