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 <mateusz_wachowiak@outlook.com>
This commit is contained in:
SpecificProtagonist 2024-03-08 17:03:42 +01:00 committed by GitHub
parent c75d145869
commit da25f1de3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<KeyCode>` 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<GamepadButton>` is independent of window focus.
///
/// ## Note
///
/// When adding this resource for a new input type, you should: