<!--
{
  "availability" : [
    "macOS: 10.11.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSGestureRecognizerDelegate/gestureRecognizer(_:shouldAttemptToRecognizeWith:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSGestureRecognizerDelegate(im)gestureRecognizer:shouldAttemptToRecognizeWithEvent:"
  },
  "title" : "gestureRecognizer(_:shouldAttemptToRecognizeWith:)"
}
-->

# gestureRecognizer(_:shouldAttemptToRecognizeWith:)

Asks the delegate if a gesture recognizer should attempt to recognize gestures for a particular event.

```
@MainActor optional func gestureRecognizer(_ gestureRecognizer: NSGestureRecognizer, shouldAttemptToRecognizeWith event: NSEvent) -> Bool
```

## Parameters

`gestureRecognizer`

The gesture recognizer object that is interpreting events. This is the object with which the delegate is associated.

`event`

An event object associated with the request.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> to allow the gesture recognizer to begin recognizing gestures for the specified event, or <doc://com.apple.documentation/documentation/Swift/false> to prevent it from recognizing gestures for the specified event. If you do not implement this method, the default return value is <doc://com.apple.documentation/documentation/Swift/true>.

## Discussion

This method is called when a target view recognizes a new gesture event stream. The target view calls this method to determine whether the gesture recognizer should process events for the stream, or opt out of them. Returning <doc://com.apple.documentation/documentation/Swift/false> from this method causes the gesture recognizer to opt out, and prevents the other delegate methods from being called for the event stream.

---

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)