Re: Custom View drawn twice?
Re: Custom View drawn twice?
- Subject: Re: Custom View drawn twice?
- From: Uli Kusterer <email@hidden>
- Date: Fri, 14 Mar 2008 13:11:28 +0100
On 14.03.2008, at 09:11, Ben Lachman wrote:
I think I finally solved this while chatting with Wil Shipley
earlier this evening. Wil mentioned sometimes needing to display
from the opaque ancestor which is basically what I was trying to do
with the code Uli questioned. The way I was doing it was only
partially successful at best. Given Wil's hints, I added the
following to my drawing code and my drawing glitches are no more:
- (void)drawRect:(NSRect)rect {
static BOOL toggle = YES;
if( toggle ) {
toggle = NO;
[[self opaqueAncestor] display];
return;
} else {
toggle = YES;
}
...
Urk. That does not sound like a good idea at all. display is
supposed to eventually call -drawRect:, and also the -drawRect: of any
subviews that might need redrawing. Calling display inside -drawRect:
is essentially requesting an endless recursion from Apple. Even if it
works now due to some fortunate optimization or whatever Apple put in,
I don't think this is a good idea going forward.
I think what you really should do is do this call wherever you call -
setNeedsDisplay: or -display: on your view. *not* in -drawRect:. Even
then, it's highly dubious code that should not be required at all. If
you have to call display on the opaque ancestor and calling display on
the view itself doesn't work, I would definitely recommend you file a
bug on that, ideally including a sample application that reproduces
the issue.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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