Re: white screen windows at first
Re: white screen windows at first
- Subject: Re: white screen windows at first
- From: Graham Cox <email@hidden>
- Date: Thu, 29 Apr 2010 11:23:08 +1000
On 29/04/2010, at 4:29 AM, Bill Appleton wrote:
> so is it "legal" to draw on an NSWindow from some other event?
Yes, but only under specific, controlled conditions.
The intended model is to draw *everything* in -drawRect:. If you arrange your code to do this, not only will life be easy, but you'll get the benefit of drawing optimisations that are built-in.
The way to do it is:
* on an event, make a note of the state change of your view.
* mark the relevant area as needing update using - needsDisplayInRect:
* in -drawRect:, use the state information to draw everything you need to draw in the appropriate state
So for example if you want to highlight something during mouse tracking, on mouse down set a flag, on mouse up, clear it. In drawRect, if the flag is set, draw the highlight, otherwise don't. In general you want to avoid trying to draw directly in response to the event itself.
--Graham
_______________________________________________
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