Electron.NET icon indicating copy to clipboard operation
Electron.NET copied to clipboard

How to prevent electron window closing when click close and ask confirmation

Open soundararajans opened this issue 4 years ago • 1 comments

How to prevent electron window closing when click close and ask confirmation

  • Node Version: V 14.17.0
  • Electron.Net Nuget: 11.5.1
  • Target: Win
  • .Net: Net5.0

I tried the below code. But it's not working and window is closing always without asking confirmation.

` window.OnClose += () => {
MessageBoxOptions options = new MessageBoxOptions("Changes you made may not be saved"); options.Type = MessageBoxType.question; options.Buttons = new string[] { "No", "Yes" }; options.DefaultId = 1; options.CancelId = 0;

            if (Electron.Dialog.ShowMessageBoxAsync(options).Result.Response == 1)
            {
               
            }
        };

`

soundararajans avatar May 13 '21 14:05 soundararajans

The same question

NepPure avatar Aug 19 '21 09:08 NepPure

🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉

With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!

GregorBiswanger avatar Mar 28 '23 15:03 GregorBiswanger