• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
clearing NSView outside of drawRect:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

clearing NSView outside of drawRect:


  • Subject: clearing NSView outside of drawRect:
  • From: Chinh Nguyen <email@hidden>
  • Date: Thu, 11 Sep 2008 16:09:38 -0500

How do you clear an NSView when drawing outside of drawRect:?

I added and positioned a custom view on top another view (addSubView:positioned:relativeTo:) that draws a complex image so that I can draw selections in my custom view without having to worry about redrawing my original image or using a cached image. Inside my mouseDragged: implementation, I lock my custom view's focus, attempt to erase the view using fillRect with clearColor (which doesn't work), draw my selection, then unlock the focus. When that didn't work (and I tried returning yes and no for isOpaque), I went ahead and just did a setNeedsDisplay:YES on my custom view and just drew the selection in drawRect:. That works but there's a noticeable lag while the mouse is being dragged.

In Carbon, I was able to do the above by using an overlay and CGContextClearRect(). The only thing I can think of to try next is to use similar logic in Cocoa and to place the custom view in a borderless window and use NSRectFillUsingOperation(rect, NSCompositeClear). I was hoping to avoid having to do that and deal with keeping the two view's positions and sizes in sync.

-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


  • Follow-Ups:
    • Re: clearing NSView outside of drawRect:
      • From: "Ken Ferry" <email@hidden>
    • Re: clearing NSView outside of drawRect:
      • From: "Michael Ash" <email@hidden>
  • Prev by Date: making keyboard shortcuts work on different keyboard layouts
  • Next by Date: Animate a CGPath
  • Previous by thread: making keyboard shortcuts work on different keyboard layouts
  • Next by thread: Re: clearing NSView outside of drawRect:
  • Index(es):
    • Date
    • Thread