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:
@@ -96,7 +96,9 @@ impl crate::View for Modals {
|
||||
*save_modal_open = true;
|
||||
}
|
||||
if ui.button("Cancel").clicked() {
|
||||
*user_modal_open = false;
|
||||
// You can call `ui.close()` to close the modal.
|
||||
// (This causes the current modals `should_close` to return true)
|
||||
ui.close();
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -123,7 +125,7 @@ impl crate::View for Modals {
|
||||
}
|
||||
|
||||
if ui.button("No Thanks").clicked() {
|
||||
*save_modal_open = false;
|
||||
ui.close();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user