How to use Mac OS X Cocoa events for multi-touch gestures

I am writing a program with NSView built into NSScrollView that the user can scale. I would like to configure it so that the user can zoom in using the hard multitouch pinch supported by MacBook Air and the new Unibody MacBooks / MacBooks Pro and in applications like Safari and iPhoto. I hunted for Apple documentation and cannot figure out how to do this.

  • Is this supported by the public APIs in Mac OS X 10.5 Leopard?
  • If not, how bad are private APIs (for example, is it just an undeclared constant or a whole new set of methods)?
+4
source share
1 answer

Edit: Snow Leopard adds supported APIs for gestures and multi-touch. See AppKit Release Notes for Snow Leopard ; ⌘F for gestures and MultiTouch (sic). They will look pretty familiar if you used them below, but there are probably slight differences, so read the new documentation anyway.


Is this supported by the public APIs on Mac OS X 10.5 Leopard?

No. 10.5.0 does not support it at all, and from 10.5.1 to 10.5.6 you implement undocumented methods.

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

Not bad. You must implement some undocumented event methods in your view. Since you are the one who implements these methods, you should not crash if Apple changes the methods; whatever happens, it will stop working.

However, if you receive an absolute (not delta) increase or rotation from the event, then these are still undocumented event methods, so you should protect these messages with respondsToSelector: messages and do a thorough check of the range of returned method values.

+12
source

All Articles