Make `close_popup` take an `Id` and add `close_all_popups` (#5820)
Ooops, fixes a regression introduced in #5799 * [x] I have followed the instructions in the PR template
This commit is contained in:
parent
1aced06e47
commit
a2afc8d092
|
|
@ -85,7 +85,7 @@ pub enum PopupCloseBehavior {
|
|||
/// but in the popup's body
|
||||
CloseOnClickOutside,
|
||||
|
||||
/// Clicks will be ignored. Popup might be closed manually by calling [`crate::Memory::close_popup`]
|
||||
/// Clicks will be ignored. Popup might be closed manually by calling [`crate::Memory::close_all_popups`]
|
||||
/// or by pressing the escape button
|
||||
IgnoreClicks,
|
||||
}
|
||||
|
|
@ -524,7 +524,7 @@ impl<'a> Popup<'a> {
|
|||
_ => mem.open_popup(id),
|
||||
}
|
||||
} else {
|
||||
mem.close_popup();
|
||||
mem.close_popup(id);
|
||||
}
|
||||
}
|
||||
Some(SetOpenCommand::Toggle) => {
|
||||
|
|
@ -606,7 +606,7 @@ impl<'a> Popup<'a> {
|
|||
}
|
||||
OpenKind::Memory { .. } => {
|
||||
if should_close {
|
||||
ctx.memory_mut(|mem| mem.close_popup());
|
||||
ctx.memory_mut(|mem| mem.close_popup(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1098,17 +1098,26 @@ impl Memory {
|
|||
.and_then(|(popup_id, pos)| if popup_id == id { pos } else { None })
|
||||
}
|
||||
|
||||
/// Close the open popup, if any.
|
||||
pub fn close_popup(&mut self) {
|
||||
/// Close any currently open popup.
|
||||
pub fn close_all_popups(&mut self) {
|
||||
self.popup = None;
|
||||
}
|
||||
|
||||
/// Close the given popup, if it is open.
|
||||
///
|
||||
/// See also [`Self::close_all_popups`] if you want to close any / all currently open popups.
|
||||
pub fn close_popup(&mut self, popup_id: Id) {
|
||||
if self.is_popup_open(popup_id) {
|
||||
self.popup = None;
|
||||
}
|
||||
}
|
||||
|
||||
/// Toggle the given popup between closed and open.
|
||||
///
|
||||
/// Note: At most, only one popup can be open at a time.
|
||||
pub fn toggle_popup(&mut self, popup_id: Id) {
|
||||
if self.is_popup_open(popup_id) {
|
||||
self.close_popup();
|
||||
self.close_popup(popup_id);
|
||||
} else {
|
||||
self.open_popup(popup_id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -521,7 +521,7 @@ pub fn color_edit_button_hsva(ui: &mut Ui, hsva: &mut Hsva, alpha: Alpha) -> Res
|
|||
if !button_response.clicked()
|
||||
&& (ui.input(|i| i.key_pressed(Key::Escape)) || area_response.clicked_elsewhere())
|
||||
{
|
||||
ui.memory_mut(|mem| mem.close_popup());
|
||||
ui.memory_mut(|mem| mem.close_popup(popup_id));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue