<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/allowsWindowActivationEvents(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE28allowsWindowActivationEventsyQrSbSgF"
  },
  "title" : "allowsWindowActivationEvents(_:)"
}
-->

# allowsWindowActivationEvents(_:)

Configures whether gestures in this view hierarchy can handle events
that activate the containing window.

```
nonisolated func allowsWindowActivationEvents(_ value: Bool?) -> some View
```

## Parameters

`value`

A Boolean value that indicates whether gestures in this
view hierarchy can handle events that activate the containing
window. If `nil`, or if the modifier is not present, the behavior
will be inherited from the view’s ancestors.

## Discussion

Views higher in the hierarchy can override the value you set on this
view. In the following example, the tap gesture on the `Rectangle` won’t
handle events that activate the containing window because the outer
`allowsWindowActivationEvents(_:)` view modifier overrides the
inner one:

```
HStack {
    Rectangle()
        .onTapGesture { ... }
        .allowsWindowActivationEvents()
}
.allowsWindowActivationEvents(false)
```

> Note: It’s only possible to disallow handling events that activate the
> containing window for views that allow it by default or that inherit
> this behavior from their ancestors. Views that explicitly already
> disallow this functionality can’t have it turned on.

> Note: Prefer using ``doc://com.apple.SwiftUI/documentation/SwiftUI/View/allowsWindowActivationEvents()`` if the
> parameter is always `true` and it never changes.

---

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)