allowsWindowActivationEvents

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

View ModifieriOS 18.0+macOS 15.0+visionOS 2.0+

Overloads

2 ways to call compose().allowsWindowActivationEvents(). Each is one SwiftUI overload, picked by the arguments you pass.

React
compose().allowsWindowActivationEvents(value: boolean | null)
Swift
nonisolated func allowsWindowActivationEvents(
    _ value: Bool?
) -> some View

Parameters

  • value*boolean | null

    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)

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.

parameter is always true and it never changes.

See also

More in Input and interaction.