-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - add documentation on Input
#1781
Conversation
Looks good. I like the |
crates/bevy_input/src/input.rs
Outdated
/// Check if `input` has been just pressed, and clear it so that it won't be processed further. | ||
pub fn just_pressed_and_clear(&mut self, input: T) -> bool { | ||
self.just_pressed.remove(&input); | ||
self.just_pressed.contains(&input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always return false because we just removed input in the previous line. I'll just fix this now because its easy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sometime I really miss the 🤦♂️ emoji reaction on GitHub... sorry about that one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha no worries. This is a class of mistake that we all make 😄
I renamed |
bors r+ |
related to #1700 This PR: * documents all methods on `Input<T>` * adds documentation on the struct about how to use it, and how to implement it for a new input type * renames method `update` to a easier to understand `clear` * adds two methods to check for state and clear it after, allowing easier use in the case of #1700 Co-authored-by: Carter Anderson <mcanders1@gmail.com>
Pull request successfully merged into main. Build succeeded: |
Input
Input
related to bevyengine#1700 This PR: * documents all methods on `Input<T>` * adds documentation on the struct about how to use it, and how to implement it for a new input type * renames method `update` to a easier to understand `clear` * adds two methods to check for state and clear it after, allowing easier use in the case of bevyengine#1700 Co-authored-by: Carter Anderson <mcanders1@gmail.com>
/// but only one should react, for example in the case of triggering | ||
/// [`State`] change, you should consider clearing the input state, either by: | ||
/// | ||
/// * Using [`Input::just_pressed_and_clear`] or [`Input::just_released_and_clear`] instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to note that these no longer exist with the changes that @cart pushed to this PR (just_pressed_and_clear
-> clear_just_pressed
).
It might be a good idea to enable rustdoc linting on the CI to catch issues like there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix a few dead links * Links in `Input` missed a refactor * `Reflect::downcast` can't use the intra doc link format, as it's not a link to a trait function, but to a function implemented on `dyn Reflect` noticed in #1781 (comment)
related to bevyengine#1700 This PR: * documents all methods on `Input<T>` * adds documentation on the struct about how to use it, and how to implement it for a new input type * renames method `update` to a easier to understand `clear` * adds two methods to check for state and clear it after, allowing easier use in the case of bevyengine#1700 Co-authored-by: Carter Anderson <mcanders1@gmail.com>
fix a few dead links * Links in `Input` missed a refactor * `Reflect::downcast` can't use the intra doc link format, as it's not a link to a trait function, but to a function implemented on `dyn Reflect` noticed in bevyengine#1781 (comment)
related to #1700
This PR:
Input<T>
update
to a easier to understandclear