Browse Source

egui-winit: Recognize numpad enter/plus/minus (#3285)

Numpad enter should work the same as the normal return key.

Numpad plus/minus should now work for scaling ui
(together with cmd/ctrl)
pull/3286/head
Emil Ernerfeldt 1 year ago
committed by GitHub
parent
commit
a59eda7a27
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      crates/egui-winit/src/lib.rs

8
crates/egui-winit/src/lib.rs

@ -770,7 +770,7 @@ fn translate_virtual_key_code(key: winit::event::VirtualKeyCode) -> Option<egui:
VirtualKeyCode::Escape => Key::Escape,
VirtualKeyCode::Tab => Key::Tab,
VirtualKeyCode::Back => Key::Backspace,
VirtualKeyCode::Return => Key::Enter,
VirtualKeyCode::Return | VirtualKeyCode::NumpadEnter => Key::Enter,
VirtualKeyCode::Space => Key::Space,
VirtualKeyCode::Insert => Key::Insert,
@ -780,10 +780,12 @@ fn translate_virtual_key_code(key: winit::event::VirtualKeyCode) -> Option<egui:
VirtualKeyCode::PageUp => Key::PageUp,
VirtualKeyCode::PageDown => Key::PageDown,
VirtualKeyCode::Minus => Key::Minus,
VirtualKeyCode::Minus | VirtualKeyCode::NumpadSubtract => Key::Minus,
// Using Mac the key with the Plus sign on it is reported as the Equals key
// (with both English and Swedish keyboard).
VirtualKeyCode::Equals => Key::PlusEquals,
VirtualKeyCode::Equals | VirtualKeyCode::Plus | VirtualKeyCode::NumpadAdd => {
Key::PlusEquals
}
VirtualKeyCode::Key0 | VirtualKeyCode::Numpad0 => Key::Num0,
VirtualKeyCode::Key1 | VirtualKeyCode::Numpad1 => Key::Num1,

Loading…
Cancel
Save