---
title: "canBePrevented(by:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsgesturerecognizer/canbeprevented(by:)"
---

# canBePrevented(by:)

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

## Declaration

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

## Parameters

- `preventingGestureRecognizer`: The gesture recognizer that can prevent the current object from recognizing its gesture.

## Return Value

Return Value true to indicate that preventingGestureRecognizer can block the current gesture recognizer from recognizing its gesture, or false if both gesture recognizers can operate simultaneously.

## Discussion

Discussion This method enables similar behavior as the gestureRecognizerShouldBegin(_:) and 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.

## See Also

### Methods for Subclasses

- [reset()](appkit/nsgesturerecognizer/reset().md)
- [mouseDown(with:)](appkit/nsgesturerecognizer/mousedown(with:).md)
- [mouseDragged(with:)](appkit/nsgesturerecognizer/mousedragged(with:).md)
- [mouseUp(with:)](appkit/nsgesturerecognizer/mouseup(with:).md)
- [otherMouseDown(with:)](appkit/nsgesturerecognizer/othermousedown(with:).md)
- [otherMouseDragged(with:)](appkit/nsgesturerecognizer/othermousedragged(with:).md)
- [otherMouseUp(with:)](appkit/nsgesturerecognizer/othermouseup(with:).md)
- [rightMouseDown(with:)](appkit/nsgesturerecognizer/rightmousedown(with:).md)
- [rightMouseDragged(with:)](appkit/nsgesturerecognizer/rightmousedragged(with:).md)
- [rightMouseUp(with:)](appkit/nsgesturerecognizer/rightmouseup(with:).md)
- [magnify(with:)](appkit/nsgesturerecognizer/magnify(with:).md)
- [rotate(with:)](appkit/nsgesturerecognizer/rotate(with:).md)
- [canPrevent(_:)](appkit/nsgesturerecognizer/canprevent(_:).md)
- [shouldBeRequiredToFail(by:)](appkit/nsgesturerecognizer/shouldberequiredtofail(by:).md)
- [shouldRequireFailure(of:)](appkit/nsgesturerecognizer/shouldrequirefailure(of:).md)
