diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 162ff4a739e1..d95cf21f25ae 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -2889,7 +2889,7 @@ impl Context { /// No locks are held while the given closure is called. #[allow(clippy::unused_self)] #[inline] - pub fn with_accessibility_parent(&self, _id: Id, f: impl FnOnce()) { + pub fn with_accessibility_parent(&self, _id: Id, f: impl FnOnce() -> R) -> R { // TODO(emilk): this isn't thread-safe - another thread can call this function between the push/pop calls #[cfg(feature = "accesskit")] self.frame_state_mut(|fs| { @@ -2898,7 +2898,7 @@ impl Context { } }); - f(); + let result = f(); #[cfg(feature = "accesskit")] self.frame_state_mut(|fs| { @@ -2906,6 +2906,8 @@ impl Context { assert_eq!(state.parent_stack.pop(), Some(_id)); } }); + + result } /// If AccessKit support is active for the current frame, get or create