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 PROTECTED]

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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