piston
piston copied to clipboard
Add method to Window trait to disable automatic closing
One simple thing I would like from Piston is the ability to disable automatic window closing when the window's "X" button in the top corner is pressed. For example, if I am developing some kind of editor-like interface, and the user tries to close the window, I would like to be able to intercept that close request and ask them if they would like to save their data first.
My idea would be to add automatic_close(self, bool) -> Self
and set_automatic_close(&mut self, bool)
methods to the Window
trait.
As an example, currently, in GlutinWindow
's implementation of Window
, when a close is requested, should_close
is set to true
and a Event::Input(Input::Close(CloseArgs {}))
is returned from Window::poll_event()
. If automatic_close
were set to false, then the close event could still be returned, but should_close
would not be set to true
. This would allow the user to have control over when the window actually closes.
Something to consider would be whether or not these methods should have a default implementation that does nothing, so as not to break current Window
implementors that blindly upgrade their piston
version.