Re: Mouse button down?
Re: Mouse button down?
- Subject: Re: Mouse button down?
- From: mmalcolm crawford <email@hidden>
- Date: Sat, 3 Apr 2004 13:56:00 -0800
On Apr 3, 2004, at 12:24 PM, Peter Wollschlaeger wrote:
you should override in a custom view mouseDown like:
- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint p = [theEvent locationInWindow];
p.x -= [self frame].origin.x;
p.y -= [self frame].origin.y;
}
If this code is intended to get the point's location in your own
coordinate space, in the general case it is incorrect. You should use:
- (void)mouseDown:(NSEvent *)theEvent
{
NSPoint p = [theEvent locationInWindow];
p = [self convertPoint:p fromView:nil];
}
See:
<
http://developer.apple.com/documentation/Cocoa/Reference/
ApplicationKit/ObjC_classic/Classes/NSView.html>
mmalc
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.