mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 23:00:04 -04:00
Add Key::Cut, Key::Copy, Key::Paste (#3725)
The comment added in commit 8a0bc97e ("[egui_glium] Fix paste") seems to
assume that `winit` "should have translated" common "paste" keyboard
combos to a `Cut`/`Copy`/`Paste` "KeyCode", but completely glossed over
the fact that this `KeyCode` (now also `NamedKey`) maps to a special key
dedicated to this purpose found on some keyboards and OSes. Make sure
that this key is still handled in addition to the combo that is
detected.
---
Note that this PR does not compile as it is (and I have hence not tested
this nor even ran into this limitation), just noticed this inconsistency
while failing to understand a code comment. We'd have to decide if the
variants should be added to `egui::Key` or if these helper functions
need to take `winit` keys (`ScanCode` or `NamedKey`) directly?
I should have an old keyboard with a physical paste key in a drawer
somewhere. And on Android there are special copy/paste events that can
be sent by a virtual keyboard or the debug shell, so that this can be
properly tested before it is merged.
(Except that the current `clipboard` implementation is not supported on
Android)
This commit is contained in:
@@ -879,6 +879,10 @@ pub enum Key {
|
||||
PageUp,
|
||||
PageDown,
|
||||
|
||||
Copy,
|
||||
Cut,
|
||||
Paste,
|
||||
|
||||
// ----------------------------------------------
|
||||
// Punctuation:
|
||||
/// `:`
|
||||
@@ -1005,6 +1009,9 @@ impl Key {
|
||||
Self::End,
|
||||
Self::PageUp,
|
||||
Self::PageDown,
|
||||
Self::Copy,
|
||||
Self::Cut,
|
||||
Self::Paste,
|
||||
// Punctuation:
|
||||
Self::Colon,
|
||||
Self::Comma,
|
||||
@@ -1102,6 +1109,10 @@ impl Key {
|
||||
"PageUp" => Self::PageUp,
|
||||
"PageDown" => Self::PageDown,
|
||||
|
||||
"Copy" => Self::Copy,
|
||||
"Cut" => Self::Cut,
|
||||
"Paste" => Self::Paste,
|
||||
|
||||
"Colon" | ":" => Self::Colon,
|
||||
"Comma" | "," => Self::Comma,
|
||||
"Minus" | "-" | "−" => Self::Minus,
|
||||
@@ -1209,6 +1220,10 @@ impl Key {
|
||||
Key::PageUp => "PageUp",
|
||||
Key::PageDown => "PageDown",
|
||||
|
||||
Key::Copy => "Copy",
|
||||
Key::Cut => "Cut",
|
||||
Key::Paste => "Paste",
|
||||
|
||||
Key::Colon => "Colon",
|
||||
Key::Comma => "Comma",
|
||||
Key::Minus => "Minus",
|
||||
|
||||
Reference in New Issue
Block a user