How to Highlight SwiftUI Element Being Watched in Vision Pro?

68 Views Asked by At

How to make drag and drop more user friendly in Vision Pro? When user look on an element before the drag starts some indication should exist that a certain element is looked and it is ready for dragging. How can I add a "mouse over" like feature?

I have element like this on the surface, in the space:

HStack {
    // Your content here
}
.padding(10) // Add padding for better visual indication
.background(
    RoundedRectangle(cornerRadius: 8) // Add a background shape
        .foregroundColor(Color.blue.opacity(0.3)) // Change color and opacity as needed
)
.onDrag {
    // ..
    let itemProvider = NSItemProvider(object: "YourDraggedData" as NSItemProviderWriting)
    return itemProvider
}
.onDrop(of: [UTType.text], isTargeted: nil) { providers, location in
    // ..
    return true
}
0

There are 0 best solutions below