<!--
{
  "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:7SwiftUI4ViewPAAE28allowsWindowActivationEventsQryF"
  },
  "title" : "allowsWindowActivationEvents()"
}
-->

# allowsWindowActivationEvents()

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

```
@export(implementation) nonisolated func allowsWindowActivationEvents() -> some View
```

## 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.

---

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)