On Jan 15, 2016, at 10:27 PM, Graham Cox <graham....@bigpond.com> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to