Skip to content

Commit

Permalink
Document ButtonInput behavior regarding window focus (#12367)
Browse files Browse the repository at this point in the history
# 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]>
  • Loading branch information
SpecificProtagonist and matiqo15 authored Mar 8, 2024
1 parent c75d145 commit da25f1d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crates/bevy_input/src/button_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit da25f1d

Please sign in to comment.