Re: Converting View Coordinates
Re: Converting View Coordinates
- Subject: Re: Converting View Coordinates
- From: Christopher B Hamlin <email@hidden>
- Date: Wed, 16 Jan 2002 01:33:02 -0500
On Wednesday, January 16, 2002, at 01:07 AM, Alex Keresztes wrote:
In my project I have my own custom view that overrides the
- (void)mouseDown: (NSEvent *)theEvent
so I can handle mouse clicks on that view.
I can get the screen coordinates on where the mouse was clicked by
[theEvent locationInWindow]
which returns an NSPoint.
My question is if there is any way to convert the coordinates from the
window coordinates to my
custom view's coordinates? I could potentially do this myself but I was
wondering if anyone knew of
any such functions?
Like this (see the documentation for NSView)?
- (NSPoint)convertPoint:(NSPoint)aPoint fromView:(NSView *)aView
Converts aPoint from aView's coordinate system to that of the receiver.
If aView
is nil, this method instead converts from window base coordinates. Both
aView
and the receiver must belong to the same NSWindow. Returns the converted
point.
See Also: - convertRect:fromView:, - convertSize:fromView:, -
ancestorSharedWith
View:, - contentView (NSWindow)
- Chris Hamlin