Contents

allowsWindowActivationEvents(_:)

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

Declaration

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)