Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to Window trait to disable automatic closing #1244

Open
kaikalii opened this issue Oct 9, 2018 · 0 comments
Open

Add method to Window trait to disable automatic closing #1244

kaikalii opened this issue Oct 9, 2018 · 0 comments

Comments

@kaikalii
Copy link
Contributor

kaikalii commented Oct 9, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants