diff --git a/Cargo.toml b/Cargo.toml index ae5aef96..2fd0188e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,8 +18,9 @@ opt-level = 3 members = ["./", "tools/ci", "macros"] [features] -default = ['ui'] +default = ['ui', 'block_ui_interactions'] ui = ['bevy/bevy_ui'] +block_ui_interactions = [] # If this feature is enabled, egui will have priority over actions when processing inputs egui = ['dep:bevy_egui'] diff --git a/RELEASES.md b/RELEASES.md index c05a5d99..bdce75e6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -19,6 +19,10 @@ - Added `DeadZoneShape` for `DualAxis` which allows for different deadzones shapes: cross, rectangle, and ellipse. - Added sensitivity for `SingleAxis` and `DualAxis`, allowing you to scale mouse, keypad and gamepad inputs differently for each action. +### Usability + +- Added `block_ui_interactions` feature flag; when on, mouse input won't be read if any `bevy_ui` element has an active `Interaction`. + ## Version 0.10 ### Usability diff --git a/src/systems.rs b/src/systems.rs index 7f8cd66d..9cc93e8d 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -72,7 +72,9 @@ pub fn update_action_state( mouse_wheel: Option>>, mouse_motion: Res>, clash_strategy: Res, - #[cfg(feature = "ui")] interactions: Query<&Interaction>, + #[cfg(all(feature = "ui", feature = "block_ui_interactions"))] interactions: Query< + &Interaction, + >, #[cfg(feature = "egui")] mut maybe_egui: EguiContexts, action_state: Option>>, input_map: Option>>, @@ -94,7 +96,7 @@ pub fn update_action_state( let mouse_motion = mouse_motion.into_inner(); // If use clicks on a button, do not apply them to the game state - #[cfg(feature = "ui")] + #[cfg(all(feature = "ui", feature = "block_ui_interactions"))] let (mouse_buttons, mouse_wheel) = if interactions .iter() .any(|&interaction| interaction != Interaction::None)