Re: Converting point struct from superview to subview
Re: Converting point struct from superview to subview
- Subject: Re: Converting point struct from superview to subview
- From: Fritz Anderson <email@hidden>
- Date: Fri, 24 Jun 2005 10:54:45 -0500
On 24 Jun 2005, at 10:37 AM, Ian was here wrote:
I have an NSTextView positioned within an NSView. I am
trying to get the mouse coordinates within the
NSTextView. I'm using the following code in the
NSTextView subclass:
NSPoint p = [self convertPoint:[NSEvent
mouseLocation] fromView:[self superview]]; // Get
mouse coordinates within the NSTextView.
+[NSEvent mouseLocation] returns the mouse position in screen
coordinates, not in the coordinates of your view's superview.
Assuming you're doing this from within a mouseDown: handler, and
therefore have access to an instance of an event, use [anEvent
locationInWindow] to get the location, and pass that point, and nil,
to convertPoint:fromView:. A nil view parameter in
convertPoint:fromView: converts the point from window coordinates.
-- F
_______________________________________________
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