• 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: drawRect: called twice for NSView subclass.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: drawRect: called twice for NSView subclass.


  • Subject: Re: drawRect: called twice for NSView subclass.
  • From: David Duncan <email@hidden>
  • Date: Sun, 20 Apr 2008 11:13:04 -0700

On Apr 19, 2008, at 5:15 PM, William Hunt wrote:

Essentially I have a window with a custom view atop a button. What happens at each refresh, however, is that the custom view's drawRect: is called twice. First it is called with the whole window's NSRect, then it is called with the "proper" NSRect. The result is that if I draw a circle at (0,0), it gets drawn twice at different locations:

What is going on here? Is this buggy behavior or correct behavior? My code is basically a new Cocoa application with a single NSView subclass. There is absolutely nothing funny (that I know of) going on here. That leads me to believe that the behavior is "correct," and that I'm just missing something.

For the record, I only want the one call to drawRect:, the one with the "proper" NSRect.


FYI, the "proper" rect is not guaranteed to be the bounds rect of your view either. If Cocoa only needs you to refresh a subsection of your view, then you will get a -drawRect: with just that subsection. In general, you should only use the rect passed to you in -drawRect: as a guideline for what needs to be updated (i.e. for rejection tests) rather than to define the coordinate system to draw into.
--
David Duncan
Apple DTS Animation and Printing
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: 
 >drawRect: called twice for NSView subclass. (From: William Hunt <email@hidden>)

  • Prev by Date: Re: Binding NSButton enabled state
  • Next by Date: Re: horizontal sizeToFit of NSTextView or NSTextField
  • Previous by thread: Re: drawRect: called twice for NSView subclass.
  • Next by thread: NSPopupButton Bindings
  • Index(es):
    • Date
    • Thread