mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 23:00:04 -04:00
Add Ui::close and Response::should_close (#5729)
This adds a generic way of telling containers to close from their child `Ui`s. * Part of #5727 * [x] I have followed the instructions in the PR template --------- Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use egui::Vec2b;
|
||||
use egui::{UiKind, Vec2b};
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
@@ -149,6 +149,16 @@ impl crate::View for WindowOptions {
|
||||
self.disabled_time = ui.input(|i| i.time);
|
||||
}
|
||||
egui::reset_button(ui, self, "Reset");
|
||||
if ui
|
||||
.button("Close")
|
||||
.on_hover_text("You can collapse / close Windows via Ui::close")
|
||||
.clicked()
|
||||
{
|
||||
// Calling close would close the collapsible within the window
|
||||
// ui.close();
|
||||
// Instead, we close the window itself
|
||||
ui.close_kind(UiKind::Window);
|
||||
}
|
||||
ui.add(crate::egui_github_link_file!());
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user