mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 14:50:03 -04:00
Support for Back button Key on Android (#7073)
When your press a Back button on Android (for example at
`native-activity`), [Winit translates this
key](47b938dbe7/src/platform_impl/android/keycodes.rs (L237C42-L237C53))
as `NamedKey::BrowserBack`. Added convertion to `Key::Escape` at
`egui-winit` module.
---------
Co-authored-by: Advocat <advocat@ogr.local>
This commit is contained in:
@@ -183,6 +183,11 @@ pub enum Key {
|
||||
F33,
|
||||
F34,
|
||||
F35,
|
||||
|
||||
/// Back navigation key from multimedia keyboard.
|
||||
/// Android sends this key on Back button press.
|
||||
/// Does not work on Web.
|
||||
BrowserBack,
|
||||
// When adding keys, remember to also update:
|
||||
// * crates/egui-winit/src/lib.rs
|
||||
// * Key::ALL
|
||||
@@ -307,6 +312,8 @@ impl Key {
|
||||
Self::F33,
|
||||
Self::F34,
|
||||
Self::F35,
|
||||
// Navigation keys:
|
||||
Self::BrowserBack,
|
||||
];
|
||||
|
||||
/// Converts `"A"` to `Key::A`, `Space` to `Key::Space`, etc.
|
||||
@@ -435,6 +442,8 @@ impl Key {
|
||||
"F34" => Self::F34,
|
||||
"F35" => Self::F35,
|
||||
|
||||
"BrowserBack" => Self::BrowserBack,
|
||||
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -588,6 +597,8 @@ impl Key {
|
||||
Self::F33 => "F33",
|
||||
Self::F34 => "F34",
|
||||
Self::F35 => "F35",
|
||||
|
||||
Self::BrowserBack => "BrowserBack",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -596,7 +607,7 @@ impl Key {
|
||||
fn test_key_from_name() {
|
||||
assert_eq!(
|
||||
Key::ALL.len(),
|
||||
Key::F35 as usize + 1,
|
||||
Key::BrowserBack as usize + 1,
|
||||
"Some keys are missing in Key::ALL"
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user