• 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: How to know if an NSView has pending draws
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: How to know if an NSView has pending draws
      • From: email@hidden
References: 
 >How to know if an NSView has pending draws (From: Jeff Evans <email@hidden>)
 >Re: How to know if an NSView has pending draws (From: "Clark S. Cox III" <email@hidden>)
 >Re: How to know if an NSView has pending draws (From: Jeff Evans <email@hidden>)

  • Prev by Date: Re: Weird Problem, is this an XCode Bug?
  • Next by Date: Re: How to know if an NSView has pending draws
  • Previous by thread: Re: How to know if an NSView has pending draws
  • Next by thread: Re: How to know if an NSView has pending draws
  • Index(es):
    • Date
    • Thread