Prompt on window closing in visionOS

Hi,

When closing a WindowGroup, I want to show a prompt, and only dismiss the window when the user confirms.

How to do it?

WindowGroup(id: "A") {
    ContentView()
}

Hey @kevin_wang,

There's no supported way for you to prevent a user from closing a window with the APIs currently available. Would you be able to give me a little more context of what you're trying to accomplish, maybe there's another option you could consider.

The engineer teams would love to hear more about your use case, please file an enhancement request using Feedback Assistant. Once you file the request, please post the FB number here.

If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

Thanks,
Michael

Prompt on window closing in visionOS
 
 
Q