Skip to content

Commit

Permalink
Add Key::Quote (#4683)
Browse files Browse the repository at this point in the history
* Part of #3653

<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review your PR, but my time is limited!
-->

It was surprising to me that this key wasn't sending `Event::Key` events
(only `Event::Text`), so I added a `Key` for it.

Co-authored-by: Emil Ernerfeldt <[email protected]>
  • Loading branch information
mkeeter and emilk authored Jun 23, 2024
1 parent 44f4971 commit d7ccf4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option<egui::Key> {
KeyCode::BracketLeft => Key::OpenBracket,
KeyCode::BracketRight => Key::CloseBracket,
KeyCode::Backquote => Key::Backtick,
KeyCode::Quote => Key::Quote,

KeyCode::Cut => Key::Cut,
KeyCode::Copy => Key::Copy,
Expand Down
6 changes: 6 additions & 0 deletions crates/egui/src/data/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ pub enum Key {
/// `;`
Semicolon,

/// `'`
Quote,

// ----------------------------------------------
// Digits:
/// `0` (from main row or numpad)
Expand Down Expand Up @@ -217,6 +220,7 @@ impl Key {
Self::Slash,
Self::Pipe,
Self::Questionmark,
Self::Quote,
// Digits:
Self::Num0,
Self::Num1,
Expand Down Expand Up @@ -340,6 +344,7 @@ impl Key {
"[" | "OpenBracket" => Self::OpenBracket,
"]" | "CloseBracket" => Self::CloseBracket,
"`" | "Backtick" | "Backquote" | "Grave" => Self::Backtick,
"'" | "Quote" => Self::Quote,

"0" | "Digit0" | "Numpad0" => Self::Num0,
"1" | "Digit1" | "Numpad1" => Self::Num1,
Expand Down Expand Up @@ -488,6 +493,7 @@ impl Key {
Self::OpenBracket => "OpenBracket",
Self::CloseBracket => "CloseBracket",
Self::Backtick => "Backtick",
Self::Quote => "Quote",

Self::Num0 => "0",
Self::Num1 => "1",
Expand Down

0 comments on commit d7ccf4d

Please sign in to comment.