Skip to content
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

0.13 migration: Use clippy-approved ReceivedCharacter advice #1045

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions content/learn/migration-guides/0.12-to-0.13.md
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,19 @@ Common examples of the updated variants are as follows:

See the relevant [documentation](https://docs.rs/bevy/0.13.0/bevy/input/keyboard/enum.KeyCode.html) for more information.

#### ReceivedCharacter changes

The `char` field of [`ReceivedCharacter`] is now a [`SmolStr`], and _could_ contain multiple characters. See these [winit docs] for details.

A simple workaround if you need a `char` is to call `.chars().last()`.

It's now possible to use [`KeyEvent::logical_key`]'s `Character` variant instead if you need consistent cross-platform behavior and/or a unified event stream with non-character events.

[winit docs]: https://docs.rs/winit/0.29.10/winit/event/struct.KeyEvent.html#structfield.text
[`SmolStr`]: https://docs.rs/smol_str/0.2.1/smol_str/struct.SmolStr.html
[`ReceivedCharacter`]: https://docs.rs/bevy/latest/bevy/prelude/struct.ReceivedCharacter.html
[`KeyEvent::logical_key`]: https://docs.rs/bevy/latest/bevy/input/keyboard/struct.KeyboardInput.html#structfield.logical_key

### [Remove CanvasParentResizePlugin](https://github.com/bevyengine/bevy/pull/11057)

<div class="migration-guide-area-tags">
Expand Down Expand Up @@ -1488,14 +1501,6 @@ Consider changing usage:

`Window` has a new [`name`](https://docs.rs/bevy/latest/bevy/prelude/struct.Window.html#structfield.name) field for specifying the "window class name." If you don't need this, set it to `None`.

### [ReceivedCharacter.char is now SmolStr instead of char]

<div class="migration-guide-area-tags">
<div class="migration-guide-area-tag">Windowing</div>
</div>

To restore the previous behavior, use `.chars().nth(0)`

### [delete methods deprecated in 0.12](https://github.com/bevyengine/bevy/pull/10693)

<div class="migration-guide-area-tags">
Expand Down