diff --git a/src/context.rs b/src/context.rs index ce07ef4cb898475b977e643cbe077e197592654f..14ab8ef6becadea52ee04d06e228783203108a62 100644 --- a/src/context.rs +++ b/src/context.rs @@ -113,10 +113,19 @@ impl KayakRootContext { } } + /// Adds a kayak plugin and runs the build function on the context. pub fn add_plugin(&mut self, plugin: impl KayakUIPlugin) { plugin.build(self) } + /// Retreives the current entity that has focus or None if nothing is focused. + pub fn get_current_focus(&self) -> Option<Entity> { + if let Ok(tree) = self.focus_tree.try_read() { + return tree.current().and_then(|a| Some(a.0)); + } + None + } + /// Get's the layout for th given widget index. pub(crate) fn get_layout(&self, id: &WrappedIndex) -> Option<Rect> { if let Ok(cache) = self.layout_cache.try_read() {