Re: two things (newbie)
Re: two things (newbie)
- Subject: Re: two things (newbie)
- From: John Stiles <email@hidden>
- Date: Thu, 10 Jun 2004 08:53:30 -0700
On Jun 10, 2004, at 8:01 AM, Shawn Erickson wrote:
On Jun 10, 2004, at 7:12 AM, Rolando Abarca wrote:
On Wed, 9 Jun 2004, John Terranova wrote:
[self setNeedsDisplay:YES]; // ??
and what's the difference between that and [self display]?
The first thing is the right way and the second is the wrong way. :-)
Seriously what setNeedsDisplay does it marks things as being dirty and
hence needing to be redrawn. You can call this multiple times in a
given event loop on the same of differing view objects and the view
system will build up the set of things that needed to be redrawn. Then
when the event comes around to it all of the dirty things will be
drawn in a more optimized phase and only once. If you call display you
can easily incur over drawing, etc.
So the right way is to use setNeedsDisplay: or better yet
setNeedsDisplayInRect:. The view system will call displayIfNeeded,
etc. for you then.
Frankly, I've found the opposite was true in my code.
I had a big custom-class NSView which occasionally needed small
rectangles in it to be updated.
When I called -setNeedsDisplayInRect several times, all that happened
was that my multiple tiny rectangles were coalesced into one gigantic
rectangle. I ended up using -displayInRect to avoid this behavior.
This was under 10.2.x and 10.3.x.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.