diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 4cc84fa9..6b332efa 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -4355,6 +4355,22 @@ impl Context { }) } + /// Reads this pass's AccessKit parents so far: each id that [`Self::register_accesskit_parent`] + /// (or a widget's creation) gave a parent, mapped to that parent. + /// + /// The `Context` lock is held while the given closure is called! + /// + /// Returns `None` if accesskit is off. + pub fn with_accesskit_parents(&self, reader: impl FnOnce(&IdMap) -> R) -> Option { + self.write(|ctx| { + ctx.viewport() + .this_pass + .accesskit_state + .as_ref() + .map(|state| reader(&state.parent_map)) + }) + } + /// Report the widget with this id as the focused node of this pass's accessibility tree. /// /// This is for widgets that show an active item without taking keyboard focus, such as a