Skip to content

Commit 806ebcb

Browse files
oscargushacknus
authored andcommitted
Add F21 to F35 key bindings (emilk#4004)
<!-- 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 cranky`. * 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! --> * Closes <emilk#3990> `winit` supports up to F35, so thought it was better to just add them all.
1 parent 2105d79 commit 806ebcb

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

crates/egui-winit/src/lib.rs

+30
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,21 @@ fn key_from_named_key(named_key: winit::keyboard::NamedKey) -> Option<egui::Key>
10551055
NamedKey::F18 => Key::F18,
10561056
NamedKey::F19 => Key::F19,
10571057
NamedKey::F20 => Key::F20,
1058+
NamedKey::F21 => Key::F21,
1059+
NamedKey::F22 => Key::F22,
1060+
NamedKey::F23 => Key::F23,
1061+
NamedKey::F24 => Key::F24,
1062+
NamedKey::F25 => Key::F25,
1063+
NamedKey::F26 => Key::F26,
1064+
NamedKey::F27 => Key::F27,
1065+
NamedKey::F28 => Key::F28,
1066+
NamedKey::F29 => Key::F29,
1067+
NamedKey::F30 => Key::F30,
1068+
NamedKey::F31 => Key::F31,
1069+
NamedKey::F32 => Key::F32,
1070+
NamedKey::F33 => Key::F33,
1071+
NamedKey::F34 => Key::F34,
1072+
NamedKey::F35 => Key::F35,
10581073
_ => {
10591074
log::trace!("Unknown key: {named_key:?}");
10601075
return None;
@@ -1161,6 +1176,21 @@ fn key_from_key_code(key: winit::keyboard::KeyCode) -> Option<egui::Key> {
11611176
KeyCode::F18 => Key::F18,
11621177
KeyCode::F19 => Key::F19,
11631178
KeyCode::F20 => Key::F20,
1179+
KeyCode::F21 => Key::F21,
1180+
KeyCode::F22 => Key::F22,
1181+
KeyCode::F23 => Key::F23,
1182+
KeyCode::F24 => Key::F24,
1183+
KeyCode::F25 => Key::F25,
1184+
KeyCode::F26 => Key::F26,
1185+
KeyCode::F27 => Key::F27,
1186+
KeyCode::F28 => Key::F28,
1187+
KeyCode::F29 => Key::F29,
1188+
KeyCode::F30 => Key::F30,
1189+
KeyCode::F31 => Key::F31,
1190+
KeyCode::F32 => Key::F32,
1191+
KeyCode::F33 => Key::F33,
1192+
KeyCode::F34 => Key::F34,
1193+
KeyCode::F35 => Key::F35,
11641194

11651195
_ => {
11661196
return None;

crates/egui/src/data/key.rs

+61-1
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,21 @@ pub enum Key {
154154
F18,
155155
F19,
156156
F20,
157+
F21,
158+
F22,
159+
F23,
160+
F24,
161+
F25,
162+
F26,
163+
F27,
164+
F28,
165+
F29,
166+
F30,
167+
F31,
168+
F32,
169+
F33,
170+
F34,
171+
F35,
157172
// When adding keys, remember to also update `crates/egui-winit/src/lib.rs`
158173
// and [`Self::ALL`].
159174
// Also: don't add keys last; add them to the group they best belong to.
@@ -254,6 +269,21 @@ impl Key {
254269
Self::F18,
255270
Self::F19,
256271
Self::F20,
272+
Self::F21,
273+
Self::F22,
274+
Self::F23,
275+
Self::F24,
276+
Self::F25,
277+
Self::F26,
278+
Self::F27,
279+
Self::F28,
280+
Self::F29,
281+
Self::F30,
282+
Self::F31,
283+
Self::F32,
284+
Self::F33,
285+
Self::F34,
286+
Self::F35,
257287
];
258288

259289
/// Converts `"A"` to `Key::A`, `Space` to `Key::Space`, etc.
@@ -362,6 +392,21 @@ impl Key {
362392
"F18" => Self::F18,
363393
"F19" => Self::F19,
364394
"F20" => Self::F20,
395+
"F21" => Self::F21,
396+
"F22" => Self::F22,
397+
"F23" => Self::F23,
398+
"F24" => Self::F24,
399+
"F25" => Self::F25,
400+
"F26" => Self::F26,
401+
"F27" => Self::F27,
402+
"F28" => Self::F28,
403+
"F29" => Self::F29,
404+
"F30" => Self::F30,
405+
"F31" => Self::F31,
406+
"F32" => Self::F32,
407+
"F33" => Self::F33,
408+
"F34" => Self::F34,
409+
"F35" => Self::F35,
365410

366411
_ => return None,
367412
})
@@ -494,6 +539,21 @@ impl Key {
494539
Self::F18 => "F18",
495540
Self::F19 => "F19",
496541
Self::F20 => "F20",
542+
Self::F21 => "F21",
543+
Self::F22 => "F22",
544+
Self::F23 => "F23",
545+
Self::F24 => "F24",
546+
Self::F25 => "F25",
547+
Self::F26 => "F26",
548+
Self::F27 => "F27",
549+
Self::F28 => "F28",
550+
Self::F29 => "F29",
551+
Self::F30 => "F30",
552+
Self::F31 => "F31",
553+
Self::F32 => "F32",
554+
Self::F33 => "F33",
555+
Self::F34 => "F34",
556+
Self::F35 => "F35",
497557
}
498558
}
499559
}
@@ -502,7 +562,7 @@ impl Key {
502562
fn test_key_from_name() {
503563
assert_eq!(
504564
Key::ALL.len(),
505-
Key::F20 as usize + 1,
565+
Key::F35 as usize + 1,
506566
"Some keys are missing in Key::ALL"
507567
);
508568

0 commit comments

Comments
 (0)