• 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
Re: Custom View drawn twice?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom View drawn twice?


  • Subject: Re: Custom View drawn twice?
  • From: "Ken Ferry" <email@hidden>
  • Date: Fri, 29 Feb 2008 14:52:47 -0800

I don't see a problem in your drawRect: code, so it'd be in something
you haven't posted.  Perhaps you could post a sample application?

One possibility is that your -isOpaque method returns YES, so the view
system thinks it doesn't have to redraw your superview before asking
you to draw.

If you're subclassing NSView, you'd have to opt-in to return YES from
-isOpaque, but if you're subclassing a deeper AppKit view class, it
may already be marked as opaque.

-Ken

On Fri, Feb 29, 2008 at 11:55 AM, Ben Lachman <email@hidden> wrote:
> Well, I finally was able to get this solved, but not to my
>  satisfaction.  What I'm having to do is this:
>
>         if( ! NSContainsRect(rect, [self visibleRect]) && ! NSEqualRects
>  (rect,[self visibleRect]) ) {
>                 [self setNeedsDisplayInRect:[self bounds]];
>                 [self displayIfNeededIgnoringOpacity];
>
>                 return;
>         }
>
>  which in my opinion is a really dirt hack and I'd love to find a
>  better (real?) solution.  I'm pretty sure I'm just drawing twice
>  between flushing the buffer, but I'm not sure how to debug it or
>  prevent it.  Anyone run into something like this?
>
>  Thanks,
>
> ->Ben
>  --
>  Ben Lachman
>  Acacia Tree Software
>
>  http://acaciatreesoftware.com
>
>  email@hidden
>  740.590.0009
>
>
>
>
> On Feb 21, 2008, at 1:23 AM, Ben Lachman wrote:
>
>  > I have a text view that contains a custom view which in turn
>  > contains an imageview and draws an image and a drop shadow.  During
>  > selection the bits of the view which are not fully opaque (the
>  > shadow and the image) sometimes draw twice, producing a darker
>  > shadow than I want.  This seems to alternate with normal looking
>  > drawing, so when I select text the shadow flickers between regular
>  > and darker along with the other non-opaque bits in the image.  My
>  > method for drawing the shadow looks like this:
>  >
>  > - (void)drawRect:(NSRect)rect {
>  >       NSAffineTransform *xform = [NSAffineTransform transform];
>  >
>  >       [NSGraphicsContext saveGraphicsState];
>  >
>  >       [xform translateXBy:imageViewOrigin.x yBy:imageViewOrigin.y];
>  >       [xform rotateByDegrees:rotation];
>  >       [xform concat];
>  >
>  >       NSShadow *imageShadow = [[NSShadow alloc] init];
>  >       [imageShadow setShadowOffset:NSMakeSize(0,-5)];
>  >       [imageShadow setShadowBlurRadius:5];
>  >       [imageShadow setShadowColor:[NSColor blackColor]];
>  >
>  >       [imageShadow set];
>  >       [[NSColor whiteColor] set];
>  >       [NSBezierPath fillRect:[imageView bounds]];
>  >       [NSGraphicsContext restoreGraphicsState];
>  >
>  >       [imageShadow release];
>  > }
>  >
>  > I should note that the selection area does not overlap the view
>  > (custom shaped text container).  Anyone have any ideas as to what
>  > might be going wrong?
>
>
> _______________________________________________
>
>  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
>
_______________________________________________

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

References: 
 >Custom View drawn twice? (From: Ben Lachman <email@hidden>)
 >Re: Custom View drawn twice? (From: Ben Lachman <email@hidden>)

  • Prev by Date: How to make a bevel button with pop-up menu?
  • Next by Date: Scrollers on custom view appearing but not disappearing
  • Previous by thread: Re: Custom View drawn twice?
  • Next by thread: NSWindow title bar icon without representedURL
  • Index(es):
    • Date
    • Thread