<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSGestureRecognizer/canPrevent(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSGestureRecognizer(im)canPreventGestureRecognizer:"
  },
  "title" : "canPrevent(_:)"
}
-->

# canPrevent(_:)

Overridden to indicate that the current object can prevent the specified gesture recognizer from recognizing its gesture.

```
func canPrevent(_ preventedGestureRecognizer: NSGestureRecognizer) -> Bool
```

## Parameters

`preventedGestureRecognizer`

The gesture recognizer to be prevented from recognizing its gesture.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> to indicate that `preventedGestureRecognizer` should be blocked from recognizing its gesture, or <doc://com.apple.documentation/documentation/Swift/false> if both gesture recognizers can operate simultaneously.

## Discussion

This method enables similar behavior as the [`gestureRecognizerShouldBegin(_:)`](/documentation/AppKit/NSGestureRecognizerDelegate/gestureRecognizerShouldBegin(_:)) and [`gestureRecognizer(_:shouldRequireFailureOf:)`](/documentation/AppKit/NSGestureRecognizerDelegate/gestureRecognizer(_:shouldRequireFailureOf:)) methods of the gesture recognizer’s delegate. Using this method lets you define rules that apply to all instances of your custom gesture recognizer class. For example, an [`NSClickGestureRecognizer`](/documentation/AppKit/NSClickGestureRecognizer) object does not prevent another [`NSClickGestureRecognizer`](/documentation/AppKit/NSClickGestureRecognizer) object with a higher click count from recognizing its gesture.

---

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)