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

Deprecate then remove ReceivedCharacter #12639

Closed
alice-i-cecile opened this issue Mar 22, 2024 · 0 comments · Fixed by #12868
Closed

Deprecate then remove ReceivedCharacter #12639

alice-i-cecile opened this issue Mar 22, 2024 · 0 comments · Fixed by #12868
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@alice-i-cecile
Copy link
Member

Oh wow. Thanks for the context. So having KeyboardInput events carry the full info like winit's KeyEvent was a necessary move then.

Yeah, seems like we should deprecate/remove our ReceivedCharacter event then. It probably is useless now. It was in earlier versions of winit but was removed in the keyboard rework.

Originally posted by @maniwani in #12569 (reply in thread)

@alice-i-cecile alice-i-cecile added D-Trivial Nice and easy! A great choice to get started with Bevy A-Input Player input via keyboard, mouse, gamepad, and more C-Code-Quality A section of code that is hard to understand or change labels Mar 22, 2024
@alice-i-cecile alice-i-cecile changed the title Remove RemovedCharacter Deprecate then remove RemovedCharacter Mar 22, 2024
@alice-i-cecile alice-i-cecile changed the title Deprecate then remove RemovedCharacter Deprecate then remove ReceivedCharacter Mar 22, 2024
github-merge-queue bot pushed a commit that referenced this issue Apr 30, 2024
# Objective

- Partially resolves #12639.

## Solution

- Deprecate `ReceivedCharacter`.
- Replace `ReceivedCharacter` with `KeyboardInput` in the relevant
examples.

## Migration Guide

- `ReceivedCharacter` is now deprecated, use `KeyboardInput` instead.

- Before:
  ```rust
  fn listen_characters(events: EventReader<ReceivedCharacter>) {
    for event in events.read() {
      info!("{}", event.char);
    }
  }
  ```
  
  After:
  ```rust
  fn listen_characters(events: EventReader<KeyboardInput>) {
    for event in events.read() {
      // Only check for characters when the key is pressed.
      if event.state == ButtonState::Released {
        continue;
      }
// Note that some keys such as `Space` and `Tab` won't be detected as
before.
      // Instead, check for them with `Key::Space` and `Key::Tab`.
      if let Key::Character(character) = &event.logical_key {
        info!("{}", character);
      }
    }
  }
  ```

---------

Co-authored-by: Mike <mike.hsu@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant