mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Add UiBuilder::with_closable
This commit is contained in:
@@ -145,10 +145,24 @@ impl UiBuilder {
|
|||||||
///
|
///
|
||||||
/// This works by adding a [`ClosableTag`] to the [`UiStackInfo`].
|
/// This works by adding a [`ClosableTag`] to the [`UiStackInfo`].
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn closable(mut self) -> Self {
|
pub fn closable(self) -> Self {
|
||||||
self.ui_stack_info
|
self.with_closable(true)
|
||||||
.tags
|
}
|
||||||
.insert(ClosableTag::NAME, Some(Arc::new(ClosableTag::default())));
|
|
||||||
|
/// 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
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user