<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSPanGestureRecognizer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPanGestureRecognizer"
  },
  "title" : "NSPanGestureRecognizer"
}
-->

# NSPanGestureRecognizer

A continuous gesture recognizer for panning gestures.

```
class NSPanGestureRecognizer
```

## Overview

The gesture is recognized when the user clicks all of specified buttons, drags the mouse, and releases one or more of the buttons. Use the pan gesture recognizer object to retrieve the distance traveled during the pan and the location of the mouse as it pans.

Upon creation, the gesture recognizer is configured to recognize pan gestures involving only the primary button. It also delays sending primary button events to the view by setting the [`delaysPrimaryMouseButtonEvents`](/documentation/AppKit/NSGestureRecognizer/delaysPrimaryMouseButtonEvents) property to <doc://com.apple.documentation/documentation/Swift/true>. To change the set of buttons to track, modify the [`buttonMask`](/documentation/AppKit/NSPanGestureRecognizer/buttonMask) property.

In this gesture recognizer, the [`location(in:)`](/documentation/AppKit/NSGestureRecognizer/location(in:)) method always reports the current mouse point, which changes as the user drags the mouse.

## Topics

### Configuring the gesture recognizer

[`buttonMask`](/documentation/AppKit/NSPanGestureRecognizer/buttonMask)

A bit mask of the button (or buttons) required to recognize this gesture.

### Setting the number of touches

[`maximumNumberOfTouches`](/documentation/AppKit/NSPanGestureRecognizer/maximumNumberOfTouches)

The maximum number of touches allowed to recognize this gesture

[`minimumNumberOfTouches`](/documentation/AppKit/NSPanGestureRecognizer/minimumNumberOfTouches)

The minimum number of touches needed to recognize this gesture

### Tracking the location and velocity of the gesture

[`-  translationInView:`](/documentation/AppKit/NSPanGestureRecognizer/translation(in:))

The distance traveled by the mouse during the gesture.

[`-  setTranslation:inView:`](/documentation/AppKit/NSPanGestureRecognizer/setTranslation(_:in:))

Changes the current translation value of the gesture recognizer.

[`-  velocityInView:`](/documentation/AppKit/NSPanGestureRecognizer/velocity(in:))

The velocity of the pan, measured in points per second.

### Deprecated

[`numberOfTouchesRequired`](/documentation/AppKit/NSPanGestureRecognizer/numberOfTouchesRequired)

The number of necessary touches on a Touch Bar for the gesture recognizer to match.

## Relationships

### Conforms To

[`CVarArg`](/documentation/Swift/CVarArg)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

### Inherits From

[`NSGestureRecognizer`](/documentation/AppKit/NSGestureRecognizer)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)