• 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
[newbie] translating mouse location in an NSImageView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[newbie] translating mouse location in an NSImageView


  • Subject: [newbie] translating mouse location in an NSImageView
  • From: Robert Palmer Jr <email@hidden>
  • Date: Thu, 19 Sep 2002 08:42:45 -0400

sorry for the cross-post and re-post - I'm in desperate need of a solution and have not yet figured this out. NSImageView seems so simple, but I can't get past this problem.

I have a class that subclasses NSImageView. I have the NSImageView configured to scale the image proportionally. I want to be able to click on the scaled image view and determine where in the original image that click occurred. This means I need to translate the MouseEvent's coordinates into accurate coordinates in the original image coordinate space.

The question is, how do I determine the current scaling factor at which an NSImage is being drawn in an NSImageView?

Here's the basic process (I know the function names aren't correct - I don't have my code in front of me and don't remember the exact names) I have the first two steps working fine, just need the last step:

Assume I have a 1024x1024 image being displayed proportionally in a 640x480 view (which means it will actually be displayed at 480x480).

mouseClick --> get coordinates in window space
convertToViewCoor --> get coordinates of click in view space (in 640x480 range)
WHAT_GOES_HERE --> get cooridnates of click in original image space (in 1024x1024 range)

Robert Palmer, Jr
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: [newbie] translating mouse location in an NSImageView
      • From: Marco Binder <email@hidden>
  • Prev by Date: Re: stringByTrimmingCharactersInSet
  • Next by Date: Re: Adding Properties to the Address Book
  • Previous by thread: Re: stringByTrimmingCharactersInSet
  • Next by thread: Re: [newbie] translating mouse location in an NSImageView
  • Index(es):
    • Date
    • Thread