1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 22:53:14 -04:00

Add UiBuilder::with_closable

This commit is contained in:
Emil Ernerfeldt
2025-06-18 19:24:24 -07:00
parent 7ac137bfc1
commit 5a5235dab0

View File

@@ -145,10 +145,24 @@ impl UiBuilder {
///
/// This works by adding a [`ClosableTag`] to the [`UiStackInfo`].
#[inline]
pub fn closable(mut self) -> Self {
self.ui_stack_info
.tags
.insert(ClosableTag::NAME, Some(Arc::new(ClosableTag::default())));
pub fn closable(self) -> Self {
self.with_closable(true)
}
/// Make this [`Ui`] closable?
///
/// Calling [`Ui::close`] in a child [`Ui`] will mark this [`Ui`] for closing.
/// After [`Ui::close`] was called, [`Ui::should_close`] and [`crate::Response::should_close`] will
/// return `true` (for this frame).
///
/// This works by adding a [`ClosableTag`] to the [`UiStackInfo`].
#[inline]
pub fn with_closable(mut self, closable: bool) -> Self {
if closable {
self.ui_stack_info
.tags
.insert(ClosableTag::NAME, Some(Arc::new(ClosableTag::default())));
}
self
}
}