OnFormClosing / OnExitting / "Quit without saving?"

Any idea how I could make something like a OnFormClosing event work for clicking the X to close in Linux?
I can’t get a form probably because it’s through SDL2’s window but I thought something like SDL_WINDOWEVENT_CLOSE might be going on somewhere and I could catch it and ask: “Quit without saving?” and cancel the exit.

I’ve seen ppl mention AppDomain ProcessExit but I suspect that might be at a point of no return.
I also seen there’s a base.OnExitting too but I think that might be the same sort of situation.

I looked all over and couldn’t find any way to do it in Linux using cross-desktop/SDL, so I’m settling for this solution:

AppDomain.CurrentDomain.ProcessExit += OnCloseButton;

And then the OnCloseButton event says: " Save on exit? "
So, at least you can save as you exit, but unfortunately you can’t cancel the close. I suppose I could make it borderless and add a fake X close and some fake window resize controls to simulate how it should be, but this should be good enough. ;p

ps…
(I’m not sure if being able to get the correct handle from SDL would help either since I tried getting it from the process and the Form.FromHandle still results in a null - probably cuz it’s not using Form to create a window in Linux SDL)

Maybe ask the guys on the sdl site dunno.

1 Like