From 2c9b1304236f54527417a06f0b3d005ce9df7ecb Mon Sep 17 00:00:00 2001 From: francesco-cattoglio Date: Mon, 19 Dec 2022 10:55:27 +0100 Subject: [PATCH] Add `Memory::any_popup_open()` (#2464) * Added the "any_popup_open()" function * Updated CHANGELOG.md * add PR link to changelog Co-authored-by: Emil Ernerfeldt --- CHANGELOG.md | 1 + crates/egui/src/memory.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b2798c4a0dd..ab5654621db4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ NOTE: [`epaint`](crates/epaint/CHANGELOG.md), [`eframe`](crates/eframe/CHANGELOG ### Added ⭐ * `Event::Key` now has a `repeat` field that is set to `true` if the event was the result of a key-repeat ([#2435](https://github.com/emilk/egui/pull/2435)). * Add `Slider::drag_value_speed`, which lets you ask for finer precision when dragging the slider value rather than the actual slider. +* Add `Memory::any_popup_open`, which returns true if any popup is currently open ([#2464](https://github.com/emilk/egui/pull/2464)). ### Fixed 🐛 * Expose `TextEdit`'s multiline flag to AccessKit ([#2448](https://github.com/emilk/egui/pull/2448)). diff --git a/crates/egui/src/memory.rs b/crates/egui/src/memory.rs index 271780eaddd7..27b94c7a17d6 100644 --- a/crates/egui/src/memory.rs +++ b/crates/egui/src/memory.rs @@ -479,6 +479,10 @@ impl Memory { self.popup == Some(popup_id) || self.everything_is_visible() } + pub fn any_popup_open(&self) -> bool { + self.popup.is_some() || self.everything_is_visible() + } + pub fn open_popup(&mut self, popup_id: Id) { self.popup = Some(popup_id); }