Re: Deferring a selector until later, but before painting
Re: Deferring a selector until later, but before painting
- Subject: Re: Deferring a selector until later, but before painting
- From: "Ken Ferry" <email@hidden>
- Date: Thu, 6 Mar 2008 14:00:22 -0800
On Thu, Mar 6, 2008 at 9:59 AM, John Stiles <email@hidden> wrote:
> On Leopard, this solution works perfectly. I get a chance to update my
> view right before it draws, which is exactly what the doctor ordered.
>
> Any way to get this on Tiger or am I just out of luck?
Out of luck. Well, you can do the work in -drawRect:, but if any of
the work you do invalidates display, it'll be delicate code (meaning
it may be hard to get it to work right, or relatively fragile between
releases). It might be good to implement a -resolveInvalidatedStuff
method, then call it from both -viewWillDraw and -drawRect:. Then, on
Leopard, you'll never actually be doing any work in drawRect: because
you will have already resolved all state. If it works on Tiger at
that point, great, and if not, any further tricky work you do is
targeting an unchanging OS. Make sense?
> >>> I think it's unfortunate to have to resolve to subclassing for this
> >>> type of problem - The OP might end up having to subclass several
> >>> different NSControl subclasses to make it work. Perhaps NSView
> >>> should provide some sort of notification or delegation scheme to
> >>> supplement this method?
Maybe.. I was guessing that John was writing a custom view, because
that's mostly where it seems to come up. Existing Cocoa view classes
do already support an invalidation model in places where it seems
useful - consider -[NSTableView reloadData]. But, maybe. File radars
when you hit places in your real code where you'd want it. :-)
-Ken
Cocoa Frameworks
_______________________________________________
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