<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/Entity/applyTapForBehaviors()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation6EntityC20applyTapForBehaviorsSbyF"
  },
  "title" : "applyTapForBehaviors()"
}
-->

# applyTapForBehaviors()

Apply a tap to an Entity or one of its ancestors to trigger a RealityComposer behavior if one is present.

```
@MainActor @preconcurrency func applyTapForBehaviors() -> Bool
```

## Return Value

`true` if a tap trigger was fired, otherwise returns `false`.

## Discussion

This method looks for a RealityComposer tap trigger, starting with `self` and moving up the Entity hierarchy.
As soon as an entity with a tap trigger is found, the trigger is fired, and the method returns `true`.  If no
tap trigger is found, the method returns `false`.

```swift
struct ContentView: View {
  var body: some View {
    RealityView() { content in
      if let entity = try? await Entity(named: "Content") {
        content.add(entity)
      }
    }.gesture(TapGesture().targetedToAnyEntity().onEnded { value in
      if value.entity.applyTapForBehaviors() {
        // Behavior was activated
      } else {
        // Behavior was not activated
      }
    })
  }
}
```

---

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)