Re: Call NSView's -drawRect method manually
Re: Call NSView's -drawRect method manually
- Subject: Re: Call NSView's -drawRect method manually
- From: Nick <email@hidden>
- Date: Wed, 11 May 2011 17:11:14 +0300
Thanks for a detailed explanation
2011/5/11 Ken Thomases <email@hidden>:
> On May 10, 2011, at 11:26 AM, Nick wrote:
>
>> Can someone explain please, when an NSView's call -drawRect
>> (being called manually - not by a framework) actually initiates
>> redrawing of the frame and displaying everything that it had drawn,
>> and when this call "doesn't initiate a thing"?
>
> When the framework calls your -drawRect: method, it has already established a graphics context and configured it as appropriate for the view. If you just call it yourself, there's either no current graphics context or some arbitrary graphics context that isn't related to your view.
>
> It's conceivable that one could manually set up the graphics context and then call -drawRect: oneself, but it's going to be complicated and error-prone. It is not advised
>
> Search the documentation for the -lockFocus... methods of NSView -- not just the class reference, but also the mentions of it in the View Programming Guide (the Advanced Custom View Tasks page) and the Threading Programming Guide (the Thread Safety Summary page). That latter is especially important since you're working with a display link, which calls your callback on a secondary thread. It couldn't hurt to read about graphics contexts in the Quartz 2D Programming Guide and Cocoa Drawing Guide.
>
> All of that said, you should always think twice about fighting the frameworks, as has been said by others. Chances are you're doing something you shouldn't be or are making your life harder for no good reason.
>
> Regards,
> Ken
>
>
_______________________________________________
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