diff --git a/life/src/main.rs b/life/src/main.rs index 0a8149d..a976ea6 100644 --- a/life/src/main.rs +++ b/life/src/main.rs @@ -13,6 +13,7 @@ // Only because of FromTemplat macros unfortunately... #![allow(dead_code)] +use bevy::picking::hover::HoverMap; use engine::*; mod actions; @@ -786,8 +787,11 @@ fn de_spawn_cells( } /// Run condition if the UI is the active element on the screen -fn is_ui_hovered(hovered: Query<&Hovered>) -> bool { - hovered.iter().any(|Hovered(h)| *h) +fn is_ui_hovered(hover_map: Res, ui: Query<(), With>) -> bool { + hover_map + .values() // one EntityHashMap per pointer + .flat_map(|hits| hits.keys()) // every hovered entity + .any(|e| ui.contains(*e)) // is any of them a UI node? } #[cfg(debug_assertions)]