Greg Heo

Force Touch

The force is strong with Apple's new hardware and APIs.

No, it’s not a Star Wars thing; first spotted on Apple Watch, force touch is the umbrella term for pressure sensitivity on touch devices.

On the watch, a force touch (simulated with a long press on the simulator) opens up the context menu. Developers can add up to four menu items here for context-appropriate actions based on whatever’s on the watch display.

WatchKit context menu

Watch context menu

Force touch on other touch devices — iPhones and iPads — seemed like a no-brainer. But it turns out the Macs get this new technology next and the iPhone will have to wait a while longer.

No force touch?

Confirmed: Vader rocks a 5C

What do the force touch APIs look like on OS X? You can get the full details from the documentation linked on Apple’s Force Touch for Developers page, and I’ll hit some of the highlights below.

Gestures and events

NSResponder and NSGestureRecognizer have pressureChangeWithEvent: methods for you to override.

The event passed in will be an NSEvent object, which has had a pressure property for a while now; you can get a Float here with a value from 0–1.0 with the current pressure. Here’s the best line from the API documentation:

Pressure is not intended for measuring weight.

That means you need to shelve that idea for a force-touch trackpad scale app, OK? ;)

stage is a bit simpler and provides an integer property for gesture events to say whether nothing’s happening (0), it’s a click / mouse down (1) or “additional pressure” aka a force touch (2).

New buttons

OS X 10.10.3 introduces some new button types and functionality:

There’s always a fallback for non-force touch devices: drag-drop-and-wait for spring-loaded buttons, while accelerator buttons will just return a simple on/off or 0/1 value.

Force touch on iOS

What might this look like when force touch makes it to iOS, possibly later this year?