• 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: two things (newbie)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: two things (newbie)


  • Subject: Re: two things (newbie)
  • From: John Stiles <email@hidden>
  • Date: Thu, 10 Jun 2004 13:57:17 -0700

On Jun 10, 2004, at 10:03 AM, Clark Cox wrote:

On Jun 10, 2004, at 11:53, John Stiles wrote:

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.

Have you taken a look at:
-[NSView getRectsBeingDrawn:(const NSRect **)rects count:(int *)count];

??

Well, that requires 10.3, which I can't require, unfortunately. :|
_______________________________________________
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.


References: 
 >two things (newbie) (From: Rolando Abarca <email@hidden>)
 >Re: two things (newbie) (From: John Terranova <email@hidden>)
 >Re: two things (newbie) (From: Rolando Abarca <email@hidden>)
 >Re: two things (newbie) (From: Shawn Erickson <email@hidden>)
 >Re: two things (newbie) (From: John Stiles <email@hidden>)
 >Re: two things (newbie) (From: Clark Cox <email@hidden>)

  • Prev by Date: Re: a question I am ashamed to ask
  • Next by Date: Re: a question I am ashamed to ask
  • Previous by thread: Re: two things (newbie)
  • Next by thread: Re: two things (newbie)
  • Index(es):
    • Date
    • Thread