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

# canBePrevented(by:)

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

```
func canBePrevented(by preventingGestureRecognizer: NSGestureRecognizer) -> Bool
```

## Parameters

`preventingGestureRecognizer`

The gesture recognizer that can prevent the current object from recognizing its gesture.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> to indicate that `preventingGestureRecognizer` can block the current gesture recognizer 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, a gesture recognizer of a given class might want to prevent instances of the same class from recognizing at the same time.

---

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)