• 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: setNeedsDisplayInRect not triggering drawRect?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setNeedsDisplayInRect not triggering drawRect?


  • Subject: Re: setNeedsDisplayInRect not triggering drawRect?
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 3 Sep 2009 20:54:14 -0700

On Sep 3, 2009, at 20:37, Michael de Haan wrote:

Now the part that does not work.

changeViewDelta as follows:

-(IBAction) changeViewDelta: (id) sender
{
	NSRect newBounds;
	newBounds.origin.x = newBounds.origin.x + 50.0;
	newBounds.origin.y = newBounds.origin.y + 50.0;
	newBounds.size.width = 75.0;
	newBounds.size.height = 25.0;
	[self setCurrentColor:[NSColor blackColor]];
	[self setNeedsDisplayInRect:newBounds];
}

If that's your actual code, it's likely not going to work, because you're failing to initialize newBounds. So you're offsetting newBounds 50 pixels from a trash origin. If the result (whatever it is) doesn't intersect with the view bounds (which is entirely believable), the effect of setNeedsDisplayInRect: is getting optimized away by the frameworks.


I expected this to call drawRect, but it does not. I had envisioned that I would trigger drawRect, but clearly there is something I am missing. ( I had originally set up an outlet (NSView *view, with the call to it instead of "self" (in setNeedsDisplayInRect:)) but this does not do it either, and I **think** in this setup, was unnecessary?)

You don't say explicitly what class this 'changeViewDelta:' method is in. If it's in the view, then of course 'self' is the correct receiver for the message. Putting an outlet on the view, pointing to the view itself, is mere redundancy -- the effect would be the same as using 'self'.



_______________________________________________

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: setNeedsDisplayInRect not triggering drawRect?
      • From: Michael de Haan <email@hidden>
References: 
 >setNeedsDisplayInRect not triggering drawRect? (From: Michael de Haan <email@hidden>)

  • Prev by Date: setNeedsDisplayInRect not triggering drawRect?
  • Next by Date: Re: What about revamping OpenUp.app for Snow Leopard?
  • Previous by thread: setNeedsDisplayInRect not triggering drawRect?
  • Next by thread: Re: setNeedsDisplayInRect not triggering drawRect?
  • Index(es):
    • Date
    • Thread