---
title: WindowDragGesture
framework: swiftui
role: symbol
role_heading: Structure
path: swiftui/windowdraggesture
---

# WindowDragGesture

A gesture that recognizes the motion of and handles dragging a window.

## Declaration

```swift
nonisolated struct WindowDragGesture
```

## Overview

Overview To recognize a window drag gesture on a view, create and configure the gesture, and then add it to the view using the gesture(_:isEnabled:) modifier. Consider also letting the gesture allowsWindowActivationEvents(_:) so that dragging the containing window works even when it’s inactive. To add a window drag gesture to a Circle and change its color while a user performs the window drag gesture: struct MyView: View {     @GestureState var isDraggingWindow = false

var dragWindow: some Gesture {         WindowDragGesture()             .updating($isDraggingWindow) { _, state, _ in                 state = true             }     }

var body: some View {         Circle()             .fill(isDraggingWindow ? Color.green : .blue)             .frame(width: 50, height: 50)             .gesture(dragWindow)             .allowsWindowActivationEvents()     } }

## Topics

### Creating a window drag gesture

- [init()](swiftui/windowdraggesture/init().md)

### Getting the gesture’s value

- [WindowDragGesture.Value](swiftui/windowdraggesture/value.md)

## Relationships

### Conforms To

- [Gesture](swiftui/gesture.md)

## See Also

### Recognizing gestures that change over time

- [gesture(_:)](swiftui/view/gesture(_:).md)
- [gesture(_:isEnabled:)](swiftui/view/gesture(_:isenabled:).md)
- [gesture(_:name:isEnabled:)](swiftui/view/gesture(_:name:isenabled:).md)
- [gesture(_:including:)](swiftui/view/gesture(_:including:).md)
- [DragGesture](swiftui/draggesture.md)
- [MagnifyGesture](swiftui/magnifygesture.md)
- [RotateGesture](swiftui/rotategesture.md)
- [RotateGesture3D](swiftui/rotategesture3d.md)
- [GestureMask](swiftui/gesturemask.md)
