• 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: Screen <--> View Coordinate system conversion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Screen <--> View Coordinate system conversion


  • Subject: Re: Screen <--> View Coordinate system conversion
  • From: Ken Thomases <email@hidden>
  • Date: Fri, 15 Jan 2016 23:10:57 -0600

On Jan 15, 2016, at 10:27 PM, Graham Cox <email@hidden> wrote:
>
> I have a need to draw as if to the entire screen as an overlay.

> Where I’m having a problem is that I need the overlay content to match up to objects drawn in another view, in another window. This view can be scrolled and zoomed arbitrarily. So I need to convert coordinates from this original view up to the screen coordinates, then back down to my overlay window’s contentView.

NSView* view1 = /* ... */;
NSRect rect = /* some rect in view1's internal coordinate space (relative to its bounds, not its frame) */;
NSView* view2 = /* some view in another window */;

rect = [view1 convertRect:rect toView:nil];
rect = [view1.window convertRectToScreen:rect];
rect = [view2.window convertRectFromScreen:rect];
rect = [view2 convertRect:rect fromView:nil];

rect is now in view2's internal coordinate space.

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Screen <--> View Coordinate system conversion
      • From: Graham Cox <email@hidden>
References: 
 >Screen <--> View Coordinate system conversion (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Screen <--> View Coordinate system conversion
  • Next by Date: Re: Screen <--> View Coordinate system conversion
  • Previous by thread: Re: Screen <--> View Coordinate system conversion
  • Next by thread: Re: Screen <--> View Coordinate system conversion
  • Index(es):
    • Date
    • Thread