• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Converting point struct from superview to subview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Converting point struct from superview to subview (SOLVED)
      • From: Ian was here <email@hidden>
References: 
 >Converting point struct from superview to subview (From: Ian was here <email@hidden>)

  • Prev by Date: Re: Core Data relationships
  • Next by Date: Re: Converting point struct from superview to subview
  • Previous by thread: Converting point struct from superview to subview
  • Next by thread: Re: Converting point struct from superview to subview (SOLVED)
  • Index(es):
    • Date
    • Thread