Skip to content

Commit d1b08e4

Browse files
SpecificProtagonistmatiqo15
authored andcommitted
Document ButtonInput behavior regarding window focus (#12367)
# Objective `ButtonInput<KeyCode>` 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<KeyCode>`s per window. --------- Co-authored-by: Mateusz Wachowiak <[email protected]>
1 parent bd55d52 commit d1b08e4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/bevy_input/src/button_input.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ use bevy_ecs::schedule::State;
2929
/// * Using [`ButtonInput::clear_just_pressed`] or [`ButtonInput::clear_just_released`] instead.
3030
/// * Calling [`ButtonInput::clear`] or [`ButtonInput::reset`] immediately after the state change.
3131
///
32+
/// ## Window focus
33+
///
34+
/// `ButtonInput<KeyCode>` is tied to window focus. For example, if the user holds a button
35+
/// while the window loses focus, [`ButtonInput::just_released`] will be triggered. Similarly if the window
36+
/// regains focus, [`ButtonInput::just_pressed`] will be triggered. Currently this happens even if the
37+
/// focus switches from one Bevy window to another (for example because a new window was just spawned).
38+
///
39+
/// `ButtonInput<GamepadButton>` is independent of window focus.
40+
///
3241
/// ## Note
3342
///
3443
/// When adding this resource for a new input type, you should:

0 commit comments

Comments
 (0)