Re: How to know if an NSView has pending draws
Re: How to know if an NSView has pending draws
- Subject: Re: How to know if an NSView has pending draws
- From: Graham Cox <email@hidden>
- Date: Fri, 05 Feb 2016 11:26:16 +1100
> On 5 Feb 2016, at 10:52 AM, Jeff Evans <email@hidden> wrote:
>
> Clark, it's a music app; a piece is composed and placed on the screen; there's a lot of massaging going on as the music adjusts visually. I want the play of the example to begin once there are no more updates remaining. That is no noticeable delay in terms of human time, but makes a difference in the appearance.
>
> So I figure: the system presumably knows if it is about to send more redraw requests to that view. Is there any way I could know what it knows?
Personally, I think you are abusing the view here - it should obediently display what it’s told, not be part of your underlying logic.
However, there’s an easy-ish way to do what you want, if a little hacky.
- (void) drawRect:(NSRect) dirty
{
[NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(doStuffWhenIdle) object:nil];
/* do whatever you need to draw the view */
[self performSelector:@selector(doStuffWhenIdle) withObject:nil afterDelay:MY_IDLE_TIME];
}
- (void) doStuffWhenIdle
{
// will be called once there are no more -drawRect calls and MY_IDLE_TIME has elapsed
….
}
—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