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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to