Winit: CloseRequested not fired

Created on 15 Nov 2020  路  9Comments  路  Source: rust-windowing/winit

The CloseRequested event doesn't seems to be fired when winit is used without window.

OS : Windows
Winit: 0.23
Rust: 1.46

Most helpful comment

The LoopDestroyed event exists for exactly this purpose. It is guaranteed to be emitted and guaranteed to be the last event emitted.

All 9 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisduerr picture chrisduerr  路  4Comments

JDTX picture JDTX  路  3Comments

francesca64 picture francesca64  路  4Comments

francesca64 picture francesca64  路  5Comments

chrisduerr picture chrisduerr  路  3Comments