The CloseRequested event doesn't seems to be fired when winit is used without window.
OS : Windows
Winit: 0.23
Rust: 1.46
https://docs.rs/winit/0.23.0/winit/event/enum.WindowEvent.html#variant.CloseRequested
If there's no window there's no close requested, since it's for a window.
then there is no way to execute code before the app exit ? like saving data. Do i need to use another crate ?
Depends on your platform. On Windows you can use run_return instead of run.
Use run_return and what's the point of using winit (windowing toolkit), without a window?
what's the point of using winit (windowing toolkit), without a window?
key and mouse event listener
key and mouse event listener
It won't work cross platform though, on some systems you don't have key events without a window. If the goal is to write key logger platforms API may suit a bit better.
i just need it to work on Windows, and using something like winapi wasn't possible because i simply wasn't able to understand how to use it,
Then using run_return is fine for you.
The LoopDestroyed event exists for exactly this purpose. It is guaranteed to be emitted and guaranteed to be the last event emitted.
Most helpful comment
The
LoopDestroyedevent exists for exactly this purpose. It is guaranteed to be emitted and guaranteed to be the last event emitted.