1

I need to do the following in my cocoa app (OS X):

  • Allow the user to drop an image on an NSImageView.
  • Once the image is dropped project a fixed size rectangle over the image, indicating the area of the image that will be used as a thumbnail.
  • Allow the user to drag the rectangle around to pinpoint the required thumbnail.
  • Once positioned, the user clicks a button which saves images and thumbnail to files.

It is the second bullet that I would like some feedback on. My idea is to do the following:

  • In IB drop an NSImageView on my view which will accept the image.
  • Once the drop is done, create another NSView (exact same size as the NSImageView) and project it over the NSImageView and display the rectangle for the thumbnail. I will probably have to subclass NSView so it is transparent and supports drawing and repositioning of the rectangle.
  • Allow the user to drag the rectangle around. Once the user accepts the thumbnail position, create the thumbnail from the image by projecting the rectangle on the image in NSImageView.

I understand that to work with overlapping views I need to turn on layers (setWantsLayer: YES) for the parent view. However, I found some mixed reports on this, stating that overlapping instances of NSView can't be done and this can only be done using CALayer. Also if there are easier ways to capture a thumbnail off an NSImageView, input is much appreciated.

Roger
  • 4,737
  • 4
  • 43
  • 68

0 Answers0