bounds value from NSBezierpath too small?
bounds value from NSBezierpath too small?
- Subject: bounds value from NSBezierpath too small?
- From: Remco Poelstra <email@hidden>
- Date: Sat, 2 Sep 2006 23:47:02 +0200
Hi,
I'm trying to make a simple drawing app. At the moment I figured out
how I can have an object follow my mousepointer. The problem is that
the screen isn't properly redrawn. It seems that the rectangle which
should cover the old drawing is to small. I use the bounds method
from NSBezierpath to find out what rectangle I should send to
setNeedsDisplayInRect. I've the following code:
-(void)mouseMoved:(NSEvent *)event {
NSAffineTransform *transform=[NSAffineTransform transform];
NSPoint new_pos=[self convertPoint:[event locationInWindow]
fromView:nil];
[self setNeedsDisplayInRect:[new_element bounds]];
[transform translateXBy:new_pos.x-old_mouse_pos.x yBy:new_pos.y-
old_mouse_pos.y];
[new_element transformUsingAffineTransform:transform];
old_mouse_pos=new_pos;
[self setNeedsDisplayInRect:[new_element bounds]];
}
- (void)drawRect:(NSRect)rect
{
// erase the background by drawing white
[[NSColor whiteColor] set];
[NSBezierPath fillRect:rect];
if(new_element!=nil) { /*We are drawing a new element*/
[[NSColor redColor] set];
[new_element stroke];
}
}
The result I get is like this: beryllium.net/~remco/bounds.png
If I change bounds to controlPointBounds, then it all works as
expected. Why doesn't it work with the bounds method?
Thanks in advance,
Remco Poelstra
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden