From 037f9d414bb5ab175bbc445ff5a893ac7f130401 Mon Sep 17 00:00:00 2001 From: s-puig <39652109+s-puig@users.noreply.github.com> Date: Sat, 23 Mar 2024 02:26:03 +0100 Subject: [PATCH] Clarify documentation regarding just_released and just_pressed inputs (#12661) # Objective - Clarify that `ButtonInput::just_release` and `ButtonInput::just_pressed` don't imply information about the state of `ButtonInput::pressed` or their counterparts. --- crates/bevy_input/src/button_input.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/bevy_input/src/button_input.rs b/crates/bevy_input/src/button_input.rs index 821281293a..d4d4aca2f9 100644 --- a/crates/bevy_input/src/button_input.rs +++ b/crates/bevy_input/src/button_input.rs @@ -143,12 +143,14 @@ where self.just_released.extend(self.pressed.drain()); } - /// Returns `true` if the `input` has just been pressed. + /// Returns `true` if the `input` has been pressed during the current frame. + /// + /// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_released`]. pub fn just_pressed(&self, input: T) -> bool { self.just_pressed.contains(&input) } - /// Returns `true` if any item in `inputs` has just been pressed. + /// Returns `true` if any item in `inputs` has been pressed during the current frame. pub fn any_just_pressed(&self, inputs: impl IntoIterator) -> bool { inputs.into_iter().any(|it| self.just_pressed(it)) } @@ -160,7 +162,9 @@ where self.just_pressed.remove(&input) } - /// Returns `true` if the `input` has just been released. + /// Returns `true` if the `input` has been released during the current frame. + /// + /// Note: This function does not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_pressed`]. pub fn just_released(&self, input: T) -> bool { self.just_released.contains(&input) } @@ -207,11 +211,15 @@ where } /// An iterator visiting every just pressed input in arbitrary order. + /// + /// Note: Returned elements do not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_released`]. pub fn get_just_pressed(&self) -> impl ExactSizeIterator { self.just_pressed.iter() } /// An iterator visiting every just released input in arbitrary order. + /// + /// Note: Returned elements do not imply information regarding the current state of [`ButtonInput::pressed`] or [`ButtonInput::just_pressed`]. pub fn get_just_released(&self) -> impl ExactSizeIterator { self.just_released.iter() }