tags:

views:

1288

answers:

1

I'm writing a program that has an NSView embedded in an NSScrollView which user can zoom. I'd love to set it up so the user can zoom the view using the multitouch pinch gesture supported on MacBook Air and the new unibody MacBooks/MacBooks Pro and in applications like Safari and iPhoto. I've hunted through Apple's documentation and can't figure out how do to this.

  1. Is this supported using publicly available APIs on Mac OS X 10.5 Leopard?
  2. If not, how "bad" are the private APIs (e.g. is it just an undeclared constant or a whole new set of methods)?
+7  A: 

Is this supported using publicly available APIs on Mac OS X 10.5 Leopard?

No. 10.5.0 doesn't support it at all, and 10.5.1 through 10.5.6 make you implement undocumented methods.

If not, how "bad" are the private APIs (e.g. is it just an undeclared constant or a whole new set of methods)?

Not bad at all. You have to implement some undocumented event methods in your view. Since you're the one implementing the methods, you shouldn't crash if Apple changes the methods; all that will happen is the feature will stop working.

However, if you'll be retrieving the absolute (not delta) magnification or rotation from the event, then those are as-yet-undocumented methods of the event, so you should guard those messages with respondsToSelector: messages and perform careful range-checking on the methods' return values.


Edit: Snow Leopard adds supported APIs for gestures and multi-touch. See the AppKit release notes; ⌘F for “gesture” and “MultiTouch” (sic). They'll look pretty familiar if you've used the above, but there probably are some fine differences, so read the new documentation anyway.

Peter Hosey