
# Objective
In the
[`Text`](3442a13d2c/crates/bevy_text/src/text.rs (L18)
)
struct the field is named: `linebreak_behaviour`, the British spelling
of _behavior_.
**Update**, also found:
- `FileDragAndDrop::HoveredFileCancelled`
- `TouchPhase::Cancelled`
- `Touches.just_cancelled`
The majority of all spelling is in the US but when you have a lot of
contributors across the world, sometimes
spelling differences can pop up in APIs such as in this case.
For consistency, I think it would be worth a while to ensure that the
API is persistent.
Some examples:
`from_reflect.rs` has `DefaultBehavior`
TextStyle has `color` and uses the `Color` struct.
In `bevy_input/src/Touch.rs` `TouchPhase::Cancelled` and _canceled_ are
used interchangeably in the documentation
I've found that there is also the same type of discrepancies in the
documentation, though this is a low priority but is worth checking.
**Update**: I've now checked the documentation (See #8291)
## Solution
I've only renamed the inconsistencies that have breaking changes and
documentation pertaining to them. The rest of the documentation will be
changed via #8291.
Do note that the winit API is written with UK spelling, thus this may be
a cause for confusion:
`winit::event::TouchPhase::Cancelled => TouchPhase::Canceled`
`winit::event::WindowEvent::HoveredFileCancelled` -> Related to
`FileDragAndDrop::HoveredFileCanceled`
But I'm hoping to maybe outline other spelling inconsistencies in the
API, and maybe an addition to the contribution guide.
---
## Changelog
- `Text` field `linebreak_behaviour` has been renamed to
`linebreak_behavior`.
- Event `FileDragAndDrop::HoveredFileCancelled` has been renamed to
`HoveredFileCanceled`
- Function `Touches.just_cancelled` has been renamed to
`Touches.just_canceled`
- Event `TouchPhase::Cancelled` has been renamed to
`TouchPhase::Canceled`
## Migration Guide
Update where `linebreak_behaviour` is used to `linebreak_behavior`
Updated the event `FileDragAndDrop::HoveredFileCancelled` where used to
`HoveredFileCanceled`
Update `Touches.just_cancelled` where used as `Touches.just_canceled`
The event `TouchPhase::Cancelled` is now called `TouchPhase::Canceled`
39 lines
1001 B
Rust
39 lines
1001 B
Rust
//! Displays touch presses, releases, and cancels.
|
|
|
|
use bevy::{input::touch::*, prelude::*};
|
|
|
|
fn main() {
|
|
App::new()
|
|
.add_plugins(DefaultPlugins)
|
|
.add_systems(Update, touch_system)
|
|
.run();
|
|
}
|
|
|
|
fn touch_system(touches: Res<Touches>) {
|
|
for touch in touches.iter_just_pressed() {
|
|
info!(
|
|
"just pressed touch with id: {:?}, at: {:?}",
|
|
touch.id(),
|
|
touch.position()
|
|
);
|
|
}
|
|
|
|
for touch in touches.iter_just_released() {
|
|
info!(
|
|
"just released touch with id: {:?}, at: {:?}",
|
|
touch.id(),
|
|
touch.position()
|
|
);
|
|
}
|
|
|
|
for touch in touches.iter_just_canceled() {
|
|
info!("cancelled touch with id: {:?}", touch.id());
|
|
}
|
|
|
|
// you can also iterate all current touches and retrieve their state like this:
|
|
for touch in touches.iter() {
|
|
info!("active touch: {:?}", touch);
|
|
info!(" just_pressed: {}", touches.just_pressed(touch.id()));
|
|
}
|
|
}
|