• 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 to Window Coordinates
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Converting to Window Coordinates


  • Subject: Re: Converting to Window Coordinates
  • From: Dave <email@hidden>
  • Date: Wed, 22 Apr 2015 11:55:19 +0100

Hi Again Lee Ann,

Thanks a lot for this, one thing though, how do I tell which window the position is in? At present I loop through all my open windows and apply run “hitTest” on the content view until I find one.

> Another thing you've missed: converting to myContentView's coordinate space from the window's space, with [myContentView convertPoint:myWindowPoint fromView:nil] - "If aView is nil, this method instead converts from window base coordinates"

Do I have to worry about this? It seems to work, but the window I am testing in is a plain (no title bar etc) window, so the content view and the window Frame coincide, do I need to add this for safety in case the window does have a title bar?

Here is the code I am using, it seems for work ok:

myContentView = self.window.contentView;

myGlobalPoint.x = theGlobalPoint.x;
myGlobalPoint.y = NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - theGlobalPoint.y;		//Flip

myWorkRect.origin = myGlobalPoint;
myWorkRect.size = NSMakeSize(1,1);
myWorkRect = [self.window convertRectFromScreen:myWorkRect];
myWindowPoint = myWorkRect.origin;

myCocoaControlView = (LTWViewBase*) [myContentView hitTest:myWindowPoint];
if (myCocoaControlView != nil)
	{
	if ([myCocoaControlView class] == [myContentView class])
		myCocoaControlView = nil;

	else if ([[myCocoaControlView class] isSubclassOfClass:[LTWViewBase class]] == NO)
		myCocoaControlView = nil;
	}

All the Best
Dave

_______________________________________________

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: Converting to Window Coordinates
      • From: Lee Ann Rucker <email@hidden>
References: 
 >Converting to Window Coordinates (From: Dave <email@hidden>)
 >RE: Converting to Window Coordinates (From: Lee Ann Rucker <email@hidden>)
 >Re: Converting to Window Coordinates (From: Dave <email@hidden>)
 >RE: Converting to Window Coordinates (From: Lee Ann Rucker <email@hidden>)
 >Re: Converting to Window Coordinates (From: Dave <email@hidden>)
 >RE: Converting to Window Coordinates (From: Lee Ann Rucker <email@hidden>)

  • Prev by Date: Re: Crash at iOS App Startup - What Could Have Gone Wrong?
  • Next by Date: RE: Converting to Window Coordinates
  • Previous by thread: RE: Converting to Window Coordinates
  • Next by thread: RE: Converting to Window Coordinates
  • Index(es):
    • Date
    • Thread