From da25f1de3fb48cab8f435d036c5c05d15dced8ed Mon Sep 17 00:00:00 2001 From: SpecificProtagonist Date: Fri, 8 Mar 2024 17:03:42 +0100 Subject: [PATCH] Document ButtonInput behavior regarding window focus (#12367) # Objective `ButtonInput` documentation is currently incorrect/incomplete, see #12273. ## Solution Fix the documentation. I think in the future we should also stop triggering `just_pressed`/`just_released` when focus switches between two Bevy windows, as those functions are independent of the window. It could also make sense to add individual `ButtonInput`s per window. --------- Co-authored-by: Mateusz Wachowiak --- crates/bevy_input/src/button_input.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/bevy_input/src/button_input.rs b/crates/bevy_input/src/button_input.rs index 8e4c05e4b9..f4c2bf4b1f 100644 --- a/crates/bevy_input/src/button_input.rs +++ b/crates/bevy_input/src/button_input.rs @@ -29,6 +29,15 @@ use bevy_ecs::schedule::State; /// * Using [`ButtonInput::clear_just_pressed`] or [`ButtonInput::clear_just_released`] instead. /// * Calling [`ButtonInput::clear`] or [`ButtonInput::reset`] immediately after the state change. /// +/// ## Window focus +/// +/// `ButtonInput` is tied to window focus. For example, if the user holds a button +/// while the window loses focus, [`ButtonInput::just_released`] will be triggered. Similarly if the window +/// regains focus, [`ButtonInput::just_pressed`] will be triggered. Currently this happens even if the +/// focus switches from one Bevy window to another (for example because a new window was just spawned). +/// +/// `ButtonInput` is independent of window focus. +/// /// ## Note /// /// When adding this resource for a new input type, you should: