Adopting New Trackpad Features

168
© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Adopting New Trackpad Features Mastering the force Master Raleigh Ledet AppKit Engineer App Frameworks Session 217 #WWDC15

Transcript of Adopting New Trackpad Features

Page 1: Adopting New Trackpad Features

© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Adopting New Trackpad FeaturesMastering the force

Master Raleigh Ledet AppKit Engineer

App Frameworks

Session 217

#WWDC15

Page 2: Adopting New Trackpad Features

Force Touch Trackpad

Page 3: Adopting New Trackpad Features

Force Touch Trackpad

Page 4: Adopting New Trackpad Features

Force Touch Trackpad

Page 5: Adopting New Trackpad Features

Force Touch Trackpad

Page 6: Adopting New Trackpad Features

Force Touch Trackpad

Force sensor

Force sensor

Force sensor

Force sensor

Page 7: Adopting New Trackpad Features

Force Touch Trackpad

Force sensor

Force sensor

Force sensor

Force sensor

Taptic Engine

Page 8: Adopting New Trackpad Features

Force Touch Trackpad

Force sensor

Force sensor

Force sensor

Force sensor

Taptic Engine

Page 9: Adopting New Trackpad Features

Force Touch Trackpad

Force sensor

Force sensor

Force sensor

Force sensor

Taptic Engine

Page 10: Adopting New Trackpad Features

Force Touch Trackpad

Force sensor

Force sensor

Force sensor

Force sensor

Taptic Engine

Page 11: Adopting New Trackpad Features

Force Touch Trackpad

Force sensor

Force sensor

Force sensor

Force sensor

Taptic Engine

Page 12: Adopting New Trackpad Features

Force Touch Trackpad

Page 13: Adopting New Trackpad Features

Force Touch Trackpad

Click

Page 14: Adopting New Trackpad Features

Force Touch Trackpad

Page 15: Adopting New Trackpad Features

Force Touch Trackpad

Force Click

Page 16: Adopting New Trackpad Features

Force Touch Trackpad

Page 17: Adopting New Trackpad Features

Force Touch Trackpad

Page 18: Adopting New Trackpad Features

Demo

Page 19: Adopting New Trackpad Features

Force Touch Trackpad

Page 20: Adopting New Trackpad Features

Force Touch Trackpad

Page 21: Adopting New Trackpad Features

Training ScheduleBecoming a master in one day!

Squire• Accelerator Controls, Table Row Actions

Knight• Force Event Stream, Spring Loading, Alignment Feedback

Master• Configuration and Haptics

Page 22: Adopting New Trackpad Features

SquireUsing the built-in tools

Page 23: Adopting New Trackpad Features

Squire Training ScheduleUsing the built-in tools

Table Row Actions Spring Loaded ControlsAccelerator Controls

Page 24: Adopting New Trackpad Features

Table Row ActionsCase Study: Mail message list

Page 25: Adopting New Trackpad Features

Table Row ActionsCase Study: Mail message list

Page 26: Adopting New Trackpad Features

Table Row ActionsCase Study: Mail message list

NSTableViewDelegate optional func tableView(NSTableView, rowActionsForRow: NSInteger, edge: NSTableRowActionEdge) -> [NSTableViewRowAction]

Page 27: Adopting New Trackpad Features

Table Row ActionsCase Study: Mail message list

NSTableViewDelegate optional func tableView(NSTableView, rowActionsForRow: NSInteger, edge: NSTableRowActionEdge) -> [NSTableViewRowAction]

.Leading

.Trailing

Page 28: Adopting New Trackpad Features

Table Row ActionsCase Study: Mail message list

NSTableViewRowAction convenience init(style: NSTableViewRowActionStyle, title: String, handler: ((NSTableViewRowAction, Int) -> Void))

Page 29: Adopting New Trackpad Features

Table Row ActionsCase Study: Mail message list

NSTableViewRowAction convenience init(style: NSTableViewRowActionStyle, title: String, handler: ((NSTableViewRowAction, Int) -> Void))

Page 30: Adopting New Trackpad Features

Table Row ActionsCase Study: Mail message list

NSTableViewRowAction convenience init(style: NSTableViewRowActionStyle, title: String, handler: ((NSTableViewRowAction, Int) -> Void))

.Regular

.Destructive

Page 31: Adopting New Trackpad Features

Table Row ActionsCase Study: Mail message list

Page 32: Adopting New Trackpad Features

Table Row ActionsCase Study: Mail message list

Page 33: Adopting New Trackpad Features

Spring Loaded ControlsCase Study: Finder Drag and Drop Navigation

Page 34: Adopting New Trackpad Features

Spring Loaded ControlsCase Study: Finder Drag and Drop Navigation

Page 35: Adopting New Trackpad Features

Spring Loaded ControlsCase Study: Finder Drag and Drop Navigation

NSButton

var springLoaded: Bool

Page 36: Adopting New Trackpad Features

Spring Loaded ControlsCase Study: Finder Drag and Drop Navigation

NSButton

var springLoaded: Bool

Page 37: Adopting New Trackpad Features

Spring Loaded ControlsCase Study: Finder Drag and Drop Navigation

NSSegmentedControl

var springLoaded: Bool

Page 38: Adopting New Trackpad Features

Spring Loaded ControlsCase Study: Finder Drag and Drop Navigation

NSSegmentedControl

var springLoaded: Bool

Page 39: Adopting New Trackpad Features

Accelerator ControlsCase Study: Quicktime Player

Page 40: Adopting New Trackpad Features

Accelerator ControlsCase Study: Quicktime Player

Page 41: Adopting New Trackpad Features

Accelerator ControlsCase Study: Quicktime Player

Page 42: Adopting New Trackpad Features

Accelerator ControlsCase Study: Quicktime Player

NSButton

func setButtonType(NSButtonType) .AcceleratorButton .MultiLevelAcceleratorButton

Page 43: Adopting New Trackpad Features

Accelerator ControlsCase Study: Quicktime Player

NSButton

func setButtonType(NSButtonType) .AcceleratorButton .MultiLevelAcceleratorButton

Page 44: Adopting New Trackpad Features

Accelerator ControlsCase Study: Quicktime Player

NSButton

func setButtonType(NSButtonType) .AcceleratorButton .MultiLevelAcceleratorButton

var doubleValue: Double Range: 0,[1-2]

Page 45: Adopting New Trackpad Features

Accelerator ControlsCase Study: Quicktime Player

NSButton

func setButtonType(NSButtonType) .AcceleratorButton .MultiLevelAcceleratorButton

var doubleValue: Double Range: [0-5]

var maxAcceleratorLevel: Int Range: [1-5]

Page 46: Adopting New Trackpad Features

Accelerator ControlsCase Study: Quicktime Player

NSButton

func setButtonType(NSButtonType) .AcceleratorButton .MultiLevelAcceleratorButton

var doubleValue: Double Range: [0-5]

var maxAcceleratorLevel: Int Range: [1-5]

Page 47: Adopting New Trackpad Features

Accelerator ControlsCase Study: Quicktime Player

NSButton

func setButtonType(NSButtonType) .AcceleratorButton .MultiLevelAcceleratorButton

var doubleValue: Double

0 1 2 3 4 5

1X 2X 5X 10X 30X 60x

Page 48: Adopting New Trackpad Features

Accelerator ControlsCase Study: Maps

Page 49: Adopting New Trackpad Features

Accelerator ControlsCase Study: Maps

Page 50: Adopting New Trackpad Features

Accelerator ControlsCase Study: Maps

NSSegmentedControl

var trackingMode: NSSegmentSwitchTracking .MomentaryAccelerator

Page 51: Adopting New Trackpad Features

Accelerator ControlsCase Study: Maps

NSSegmentedControl

var trackingMode: NSSegmentSwitchTracking .MomentaryAccelerator

Page 52: Adopting New Trackpad Features

Accelerator ControlsCase Study: Maps

NSSegmentedControl

var trackingMode: NSSegmentSwitchTracking .MomentaryAccelerator

func doubleValueForSelectedSegment() -> Double Range: 0,[1-2]

Page 53: Adopting New Trackpad Features

Accelerator ControlsCase Study: Photos

Page 54: Adopting New Trackpad Features

Accelerator ControlsCase Study: Photos

Page 55: Adopting New Trackpad Features

Accelerator ControlsCase Study: Photos

NSControl

var continuous: Bool

Page 56: Adopting New Trackpad Features

Accelerator ControlsCase Study: Photos

NSControl

var continuous: Bool

Page 57: Adopting New Trackpad Features

Accelerator ControlsNSButton, NSSegmentedControl

Accelerated

Continuous

Time

Maps: +/- zoom buttons

Photos: previous / next photo button

Page 58: Adopting New Trackpad Features

Accelerator ControlsNSButton, NSSegmentedControl

Accelerated

Continuous

Time

Maps: +/- zoom buttons

Photos: previous / next photo button

Page 59: Adopting New Trackpad Features

Accelerator ControlsNSButton, NSSegmentedControl

Accelerated

Continuous

Time

Maps: +/- zoom buttons

Photos: previous / next photo button

Page 60: Adopting New Trackpad Features

Accelerator ControlsNSButton, NSSegmentedControl

Accelerated

Continuous

Time

Maps: +/- zoom buttons

Photos: previous / next photo button

Page 61: Adopting New Trackpad Features

Squire SummaryUsing the built-in tools

Table Row Actions Spring Loaded ControlsAccelerator Controls

Page 62: Adopting New Trackpad Features

KnightUnderstanding how the force flows

Page 63: Adopting New Trackpad Features

Knight Training ScheduleUnderstanding how the force flows

Force event streamSpring loading protocolAlignment feedback

Page 64: Adopting New Trackpad Features

Event Stream

Page 65: Adopting New Trackpad Features

Event Stream

NSLeftMouseDown

NSLeftMouseDragged

NSLeftMouseUp

NSKeyUp

NSKeyDown

NSRightMouseDown

NSRightMouseDragged

NSRightMouseUp

NSMouseEntered

NSMouseExited NSFlagsChanged

NSScrollWheel

NSEventTypeMagnify

NSEventTypeRotate

Page 66: Adopting New Trackpad Features

Event StreamPressure Gesture

NSLeftMouseDown

NSLeftMouseDragged

NSLeftMouseUp

NSKeyUp

NSKeyDown

NSRightMouseDown

NSRightMouseDragged

NSRightMouseUp

NSMouseEntered

NSMouseExited NSFlagsChanged

NSScrollWheel

NSEventTypeMagnify

NSEventTypeRotate

NSEventTypePressure

Page 67: Adopting New Trackpad Features

Event StreamPressure Gesture

NSLeftMouseDownMask

NSLeftMouseDraggedMask

NSLeftMouseUpMask

NSKeyUpMask

NSKeyDownMask

NSRightMouseDownMask

NSRightMouseDraggedMask

NSRightMouseUpMask

NSMouseEnteredMask

NSMouseExitedMask NSFlagsChangedMask

NSScrollWheelMask

NSEventMaskMagnify

NSEventMaskRotate

NSEventMaskPressure

Page 68: Adopting New Trackpad Features

Event StreamPressure Gesture

NSLeftMouseDraggedMask NSLeftMouseUpMask NSEventMaskPressure, ,

trackEventsMatchingMask(NSEventMask,…)

[ ]

Page 69: Adopting New Trackpad Features

Event StreamPressure Gesture

trackEventsMatchingMask(NSEventMask,…)

[.LeftMouseDraggedMask, .LeftMouseUpMask, .EventMaskPressure]

Page 70: Adopting New Trackpad Features

Event StreamPressure Gesture

trackEventsMatchingMask(NSEventMask,…)

func pressureChangeWithEvent(NSEvent)

[.LeftMouseDraggedMask, .LeftMouseUpMask, .EventMaskPressure]

Page 71: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure NSEventMaskPressure var phase: NSEventPhase { get } .Began -> .Changed -> .Ended

Page 72: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure NSEventMaskPressure var phase: NSEventPhase { get } var stage: Int { get }

Page 73: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure NSEventMaskPressure var phase: NSEventPhase { get } var stage: Int { get }

1 - click

Page 74: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure NSEventMaskPressure var phase: NSEventPhase { get } var stage: Int { get }

1 - click

Page 75: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure NSEventMaskPressure var phase: NSEventPhase { get } var stage: Int { get }

1 - click 2 - force click

Page 76: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure NSEventMaskPressure var phase: NSEventPhase { get } var stage: Int { get }

1 - click 2 - force click

Page 77: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure NSEventMaskPressure var phase: NSEventPhase { get } var stage: Int { get }

1 - click 2 - force click 0 - gesture release

Page 78: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure NSEventMaskPressure var phase: NSEventPhase { get } var stage: Int { get }

1 - click 2 - force click 0 - gesture release

Page 79: Adopting New Trackpad Features

21.0

0.0

Stage 1

Force

Pres

sure

Event StreamPressure Gesture

NSEventTypePressure

var pressure: Float { get } (of the current stage) Range: [0-1]

Page 80: Adopting New Trackpad Features

1.0

0.0

Pres

sure

Event StreamPressure Gesture

NSEventTypePressure

var pressure: Float { get } (of the current stage) Range: [0-1]

2Stage 1

Force

Page 81: Adopting New Trackpad Features

1.0

0.0

Pres

sure

Event StreamPressure Gesture

NSEventTypePressure

var pressure: Float { get } (of the current stage) Range: [0-1]

2Stage 1

Force

Page 82: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure

var pressure: Float { get } var stageTransition: CGFloat { get } Range: [0-1]

1.0

0.0

Stag

e Tra

nsiti

on

2Stage 1

Force

Page 83: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure

var pressure: Float { get } var stageTransition: CGFloat { get } Range: [0-1]

1.0

0.0

Stag

e Tra

nsiti

on

2Stage 1

Force

Page 84: Adopting New Trackpad Features

Event StreamPressure Gesture

NSEventTypePressure

var pressure: Float { get } var stageTransition: CGFloat { get } Range: [0-1]

1.0

0.0

Stag

e Tra

nsiti

on

2Stage 1

Force

Page 85: Adopting New Trackpad Features

User Action

Stage:

Mouse:Events

Forc

e on

trac

kpad

Pres

sure

Event StreamParallel Mouse and Pressure event streams

Time

1

0

Click threshold

Force Click threshold

Page 86: Adopting New Trackpad Features

User Action

Stage:

Mouse:Events

Forc

e on

trac

kpad

Pres

sure

Event StreamParallel Mouse and Pressure event streams

Time

1

0

Click threshold

Force Click threshold

Page 87: Adopting New Trackpad Features

User Action

Stage:

Mouse:Events

Forc

e on

trac

kpad

Pres

sure

Event StreamParallel Mouse and Pressure event streams

Time

1

0

Click threshold

Force Click threshold

Page 88: Adopting New Trackpad Features

User Action

Stage:

Mouse:Events

Forc

e on

trac

kpad

Pres

sure

Event StreamParallel Mouse and Pressure event streams

Time

1

0

Click threshold

Force Click threshold

Page 89: Adopting New Trackpad Features

User Action

Stage:

Mouse:Events

Forc

e on

trac

kpad

Pres

sure

Event StreamParallel Mouse and Pressure event streams

Time

1

0

Click threshold

Force Click threshold

Page 90: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Stage:

Mouse:

-

Move

1

0

Click threshold

Force Click threshold

Forc

e on

trac

kpad

Pres

sure

Events

User Action

Page 91: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Stage:

Mouse:

-

Move

1

0

Click threshold

Force Click threshold

Forc

e on

trac

kpad

Pres

sure

Events

User Action

Page 92: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

1

0

Click threshold

Force Click threshold

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 93: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

1

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 94: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

1

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 95: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

21

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 96: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

21

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 97: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

21

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 98: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

21

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 99: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

21

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 100: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2 11

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 101: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2 11

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 102: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2 11

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 103: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2 11

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 104: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2 11

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 105: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2 11

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 106: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2 11

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 107: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2 11

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 108: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2

Up

011

0

Click threshold

Force Click threshold

Dragged

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 109: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2

Up

011

0

Click threshold

Force Click threshold

Dragged Move

-

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 110: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

Time

Down

1-

Move

2

Up

011

0

Click threshold

Force Click threshold

Dragged Move

-

Forc

e on

trac

kpad

Pres

sure

Stage:

Mouse:Events

User Action

Page 111: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

var associatedEventMask: NSEventMask { get }

Page 112: Adopting New Trackpad Features

Event StreamParallel Mouse and Pressure event streams

var associatedEventMask: NSEventMask { get }

if ((mouseDown.associatedEventMask.contains(.EventMaskPressure)) { // Pressure Capable Device! }

Page 113: Adopting New Trackpad Features

Event StreamSummary

NSEventTypePressure NSEventMaskPressure var phase: NSEventPhase { get } var pressure: Float { get } var stage: Int { get } var stageTransition: CGFloat { get } var associatedEventMask: NSEventMask { get }

func pressureChangeWithEvent(NSEvent)

Page 114: Adopting New Trackpad Features

Spring Loading

@protocol NSSpringLoadingDestination

Page 115: Adopting New Trackpad Features

Spring Loading

@protocol NSSpringLoadingDestination required (One of these) func springLoadingEntered(NSDraggingInfo) -> NSSpringLoadingOptions

- and / or - func springLoadingUpdated(NSDraggingInfo) -> NSSpringLoadingOptions

Page 116: Adopting New Trackpad Features

@protocol NSSpringLoadingDestination required (One of these) func springLoadingEntered(NSDraggingInfo) -> NSSpringLoadingOptions

- and / or - func springLoadingUpdated(NSDraggingInfo) -> NSSpringLoadingOptions

Spring Loading

.Disabled

.Enabled

Page 117: Adopting New Trackpad Features

Spring Loading

@protocol NSSpringLoadingDestination required (One of these) func springLoadingEntered(NSDraggingInfo) -> NSSpringLoadingOptions

- and / or - func springLoadingUpdated(NSDraggingInfo) -> NSSpringLoadingOptions

.Disabled

.Enabled

.ContinuousActivation

Page 118: Adopting New Trackpad Features

Spring Loading

@protocol NSSpringLoadingDestination required (One of these) func springLoadingEntered(NSDraggingInfo) -> NSSpringLoadingOptions

- and / or - func springLoadingUpdated(NSDraggingInfo) -> NSSpringLoadingOptions

.Disabled

.Enabled

.ContinuousActivation

.NoHover

Page 119: Adopting New Trackpad Features

Spring Loading

@protocol NSSpringLoadingDestination required (One of these) func springLoadingEntered(NSDraggingInfo) -> NSSpringLoadingOptions

- and / or - func springLoadingUpdated(NSDraggingInfo) -> NSSpringLoadingOptions

@optional func springLoadingExited(NSDraggingInfo) func draggingEnded(NSDraggingInfo)

Page 120: Adopting New Trackpad Features

Spring Loading

@protocol NSSpringLoadingDestination @required func springLoadingActivated(Bool, draggingInfo: NSDraggingInfo) func springLoadingHighlightChanged(NSDraggingInfo)

Page 121: Adopting New Trackpad Features

Spring Loading

@protocol NSSpringLoadingDestination @required func springLoadingActivated(Bool, draggingInfo: NSDraggingInfo) func springLoadingHighlightChanged(NSDraggingInfo)

draggingInfo.springLoadingHighlight

NSSpringLoadingHighlight .None .Standard .Emphasized

Page 122: Adopting New Trackpad Features

Spring Loading

NSSpringLoadingDestination

Page 123: Adopting New Trackpad Features

Alignment Feedback

Page 124: Adopting New Trackpad Features

Alignment Feedback

Page 125: Adopting New Trackpad Features

Alignment Feedback

Tracking Loop

Page 126: Adopting New Trackpad Features

Tracking Loop

MouseUp?

move Item

nextEvent

Alignment Feedback

eventMaskfunc mouseDown()

setNeedsDisplay()

Page 127: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

Alignment Feedback

MouseUp?

move Item

nextEvent

NSAlignmentFeedbackFilter

setNeedsDisplay()

Page 128: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

Alignment Feedback

class func inputEventMask() -> NSEventMask

MouseUp?

move Item

nextEvent

NSAlignmentFeedbackFilter

setNeedsDisplay()

Page 129: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

Alignment Feedback

MouseUp?

NSAlignmentFeedbackFiltermove Item

nextEvent

setNeedsDisplay()

Page 130: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

Alignment Feedback

func updateWithEvent(NSEvent)

MouseUp?

NSAlignmentFeedbackFiltermove Item

nextEvent

setNeedsDisplay()

Page 131: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

Alignment Feedback

MouseUp?

NSAlignmentFeedbackFiltermove Item

nextEvent

func updateWithPanRecognizer(NSPanGestureRecognizer)

setNeedsDisplay()

Page 132: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

Alignment Feedback

MouseUp?

NSAlignmentFeedbackFiltermove Item

nextEvent

setNeedsDisplay()

Page 133: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

Alignment Feedback

MouseUp?

setNeedsDisplay()

NSAlignmentFeedbackFilter

prepareAlignment

move Item

nextEvent

Page 134: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

Alignment Feedback

MouseUp?

setNeedsDisplay()

NSAlignmentFeedbackFilter

prepareAlignment

move Item

nextEvent

Page 135: Adopting New Trackpad Features

Alignment FeedbackPreparing alignment

previous

Page 136: Adopting New Trackpad Features

Alignment FeedbackPreparing alignment

previous

default

Page 137: Adopting New Trackpad Features

Alignment FeedbackPreparing alignment

previous

default

Page 138: Adopting New Trackpad Features

Alignment FeedbackPreparing alignment

previous

default

Page 139: Adopting New Trackpad Features

Alignment FeedbackPreparing alignment

previous

default

Page 140: Adopting New Trackpad Features

Alignment Feedback

previous

default

Preparing alignment

aligned

func alignmentFeedbackTokenForHorizontalMovementInView(NSView?, previousX: CGFloat, alignedX: CGFloat, defaultX: CGFloat) -> NSAlignmentFeedbackToken?

Page 141: Adopting New Trackpad Features

Alignment Feedback

previous

default

Preparing alignment

aligned

func alignmentFeedbackTokenForHorizontalMovementInView(NSView?, previousX: CGFloat, alignedX: CGFloat, defaultX: CGFloat) -> NSAlignmentFeedbackToken?

func alignmentFeedbackTokenForVerticalMovementInView(NSView?, previousY: CGFloat, alignedY: CGFloat, defaultY: CGFloat) -> NSAlignmentFeedbackToken?

Page 142: Adopting New Trackpad Features

Alignment Feedback

previous

default

Preparing alignment

aligned

func alignmentFeedbackTokenForHorizontalMovementInView(NSView?, previousX: CGFloat, alignedX: CGFloat, defaultX: CGFloat) -> NSAlignmentFeedbackToken?

func alignmentFeedbackTokenForVerticalMovementInView(NSView?, previousY: CGFloat, alignedY: CGFloat, defaultY: CGFloat) -> NSAlignmentFeedbackToken?

Page 143: Adopting New Trackpad Features

Alignment Feedback

previous

default

Preparing alignment

aligned

func alignmentFeedbackTokenForMovementInView(NSView?, previousPoint: NSPoint, alignedPoint: NSPoint, defaultPoint: NSPoint) -> NSAlignmentFeedbackToken?

Page 144: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

MouseUp?

setNeedsDisplay()

Alignment Feedback

NSAlignmentFeedbackFilter

prepareAlignment

move Item

nextEvent

Page 145: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

MouseUp?

setNeedsDisplay()

Alignment Feedback

NSAlignmentFeedbackFilter

[<Token>]

prepareAlignment

move Item

nextEvent

Page 146: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

MouseUp?

setNeedsDisplay()

Alignment Feedback

NSAlignmentFeedbackFilter

performFeedback

[<Token>]

prepareAlignment

move Item

nextEvent

Page 147: Adopting New Trackpad Features

Tracking Loop

eventMaskfunc mouseDown()

MouseUp?

setNeedsDisplay()

Alignment Feedback

NSAlignmentFeedbackFilter

performFeedback

[<Token>]

prepareAlignment

move Item

func performFeedback([<NSAlignmentFeedbackToken>], performanceTime: NSHapticFeedbackPerformanceTime)

nextEvent

Page 148: Adopting New Trackpad Features

Alignment FeedbackFeeling it

Consistent feel across appsEasy to integrate into tracking loopsDragging, resizing, etc…

Page 149: Adopting New Trackpad Features

Knight SummaryUnderstanding how the force flows

Force event streamSpring loading protocolAlignment Feedback

Page 150: Adopting New Trackpad Features

MasterControlling the force

Page 151: Adopting New Trackpad Features

Master Training ScheduleControlling the force

Trackpad configurationHaptics

Page 152: Adopting New Trackpad Features

Trackpad ConfigurationMore than just Force Click

NSPressureConfiguration

Page 153: Adopting New Trackpad Features

Trackpad ConfigurationMore than just Force Click

NSPressureConfiguration

init(pressureBehavior: NSPressureBehavior)

Page 154: Adopting New Trackpad Features

Trackpad ConfigurationMore than just Force Click

NSPressureConfiguration

init(pressureBehavior: NSPressureBehavior)

.PrimaryDefault

.PrimaryClick

.PrimaryGeneric

.PrimaryAccelerator

.PrimaryDeepClick

.PrimaryDeepDrag

Page 155: Adopting New Trackpad Features

Trackpad ConfigurationMore than just Force Click

NSPressureConfiguration

init(pressureBehavior: NSPressureBehavior) func set()

Page 156: Adopting New Trackpad Features

Trackpad ConfigurationMore than just Force Click

NSPressureConfiguration

init(pressureBehavior: NSPressureBehavior) func set()

Set is not ideal• Only valid during a drag• Racing the user

Page 157: Adopting New Trackpad Features

Trackpad ConfigurationMore than just Force Click

Preferred approach: NSView - var pressureConfiguration: NSPressureConfiguration

• Configured before mouse down• Configured when app not responsive

Page 158: Adopting New Trackpad Features

HapticsThe Trackpad Strikes Back

Page 159: Adopting New Trackpad Features

HapticsThe Trackpad Strikes Back

Use sparinglySubtle interactions

Page 160: Adopting New Trackpad Features

HapticsThe Trackpad Strikes Back

NSHapticFeedbackManager class func defaultPerformer() -> <NSHapticFeedbackPerformer>

@protocol NSHapticFeedbackPerformer <NSObject> func performFeedbackPattern(NSHapticFeedbackPattern, performanceTime: NSHapticFeedbackPerformanceTime)

Page 161: Adopting New Trackpad Features

HapticsThe Trackpad Strikes Back

NSHapticFeedbackManager class func defaultPerformer() -> <NSHapticFeedbackPerformer>

@protocol NSHapticFeedbackPerformer <NSObject> func performFeedbackPattern(NSHapticFeedbackPattern, performanceTime: NSHapticFeedbackPerformanceTime)

Page 162: Adopting New Trackpad Features

HapticsThe Trackpad Strikes Back

NSHapticFeedbackManager class func defaultPerformer() -> <NSHapticFeedbackPerformer>

@protocol NSHapticFeedbackPerformer <NSObject> func performFeedbackPattern(NSHapticFeedbackPattern, performanceTime: NSHapticFeedbackPerformanceTime)

NSHapticFeedbackPattern .Generic .Alignment .LevelChange

Page 163: Adopting New Trackpad Features

NSHapticFeedbackManager class func defaultPerformer() -> <NSHapticFeedbackPerformer>

@protocol NSHapticFeedbackPerformer <NSObject> func performFeedbackPattern(NSHapticFeedbackPattern, performanceTime: NSHapticFeedbackPerformanceTime)

HapticsThe Trackpad Strikes Back

NSHapticFeedbackPerformanceTime .Default .Now .DrawCompleted

Page 164: Adopting New Trackpad Features

Summary

Table Row ActionsAccelerator ButtonsSpring LoadingPressure Event StreamAlignment FeedbackConfiguration Haptic Feedback

Page 165: Adopting New Trackpad Features

More Information

DocumentationForceTouchCatalogAlignmentGuideshttp://developer.apple.com/library

Technical SupportApple Developer Forumshttp://developer.apple.com/forums

General InquiriesPaul MarcosApp Frameworks [email protected]

Page 166: Adopting New Trackpad Features

Related Sessions

What’s New in Web Development in WebKit and Safari Mission Tuesday 9:00AM

What’s New in Cocoa Presidio Tuesday 1:30PM

What’s New in NSCollection View Mission Thursday 4:30PM

Page 167: Adopting New Trackpad Features

Labs

Cocoa and Force Touch and Gestures Lab Frameworks Lab A Thursday 11:00AM

Cocoa and NSCollectionView Lab Frameworks Lab B Friday 9:00AM

Page 168: Adopting New Trackpad Features