• 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: Strange result with NSView's convertPoint:toView:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strange result with NSView's convertPoint:toView:


  • Subject: Re: Strange result with NSView's convertPoint:toView:
  • From: Eric Gorr <email@hidden>
  • Date: Fri, 12 Nov 2010 12:18:03 -0500

On Nov 12, 2010, at 11:47 AM, Eric Gorr wrote:

> I have changed the contentView of my NSWindow to be a NSView which return YES for isFlipped.
>
> If I place a NSButton in the contentView of a window, I can do the following:
>
> 	NSRect	r = [view frame];
>        NSPoint	origin;
>
> 	origin = [view convertPoint:NSZeroPoint toView:[[view window] contentView]];
>
> The r.origin will say something like ( 20, 14 ) and, when I convert the point, I get back what one would expect ( 20, 14 ).
>
> The problem comes when I try to place a NSImageView in that same content view.
>
> The r.origin will say something like ( 20, 14 ), but, when I convert the point, I get back ( 20, 78 ). (The NSImageView is 64x64)
>
> I am confused as to why this would be happening. Anyone have an idea?
>
> I should be able to easily provide some sample code if that is required in this case.


I have answered my own question. This solves the problem:

	NSPoint originPoint = NSZeroPoint;

	if ( ![view isFlipped] )
	{
		originPoint.y = NSHeight( r );
	}

	origin = [view convertPoint:originPoint toView:[[view window] contentView]];


It looks like the NSButton picks up the isFlipped property of the contentView, but the NSImageView does not.

So, I need to take this into account before attempting to convert the point.

_______________________________________________

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

References: 
 >Strange result with NSView's convertPoint:toView: (From: Eric Gorr <email@hidden>)

  • Prev by Date: Strange result with NSView's convertPoint:toView:
  • Next by Date: [iPhone] Toolbar button and "Touch Down"
  • Previous by thread: Strange result with NSView's convertPoint:toView:
  • Next by thread: Re: Strange result with NSView's convertPoint:toView:
  • Index(es):
    • Date
    • Thread