-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[Close Window] Is there a method that can close window by its own button #805
Comments
In my app, I use a In short, you don't need to use the if self.show_error {
egui::Window::new("Error").show(ctx, |ui| {
if ui.button("Close").clicked() {
self.show_error = false;
}
});
} |
Thank you so much! It works! |
Work also for me. The little inconvenience of this method is that the window is no longer closable by the classic cross on the to right corner. The workaround I found is using 2 booleans. |
Yeah, this is for sure a limitation of the current design. You might be able to use a temporary bool for the let mut show_error = self.show_error;
if show_error {
egui::Window::new("Error")
.open(&mut show_error)
.show(ctx, |ui| {
if ui.button("Close").clicked() {
self.show_error = false;
}
});
}
self.show_error &= show_error; |
`toggle_config` is initialized to false, and then passed to `.open(toggle_config)`, so the config does not appear. This change also fixes closing the config window when the user press Enter, see: emilk/egui#805 (comment)
When it comes an alert message or some input situation. The simplest case is that we have two buttons "yes" and "no", we can click one of them and then the window will close automatically. At the same time, parent widget will get the choice we did.
I tried to change "open" parameter but comes a reference conflict. And I tried to do something like "frame.quit" but failed. Also in the demo app, I could not find a demo to reproduce such a situation.
The text was updated successfully, but these errors were encountered: