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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user