Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Key::Cut, Key::Copy, Key::Paste #3725

Conversation

MarijnS95
Copy link
Contributor

The comment added in commit 8a0bc97 ("[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)

@emilk
Copy link
Owner

emilk commented Dec 22, 2023

I think the proposed solution makes sense: we translate the special keys to egui::Event, but also pass them on to the user should they want to make use of them

@emilk emilk added eframe Relates to epi and eframe egui labels Dec 22, 2023
@MarijnS95 MarijnS95 force-pushed the egui-winit-handle-dedicated-cut-copy-paste-keys branch 2 times, most recently from 077cce2 to c84f88a Compare December 24, 2023 17:39
@MarijnS95
Copy link
Contributor Author

Okay, added the necessary Key variants and filled them in inside the relevant match statements.

The comment added in commit 8a0bc97 ("[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.
@MarijnS95 MarijnS95 force-pushed the egui-winit-handle-dedicated-cut-copy-paste-keys branch from c84f88a to 6f097ea Compare December 24, 2023 17:41
@emilk emilk changed the title egui-winit: Handle Cut, Copy and Paste commands Add Key::Cut, Key::Copy, Key::Paste Dec 25, 2023
@emilk emilk added the egui-winit porblems related to winit label Dec 25, 2023
@emilk emilk merged commit 5b591d2 into emilk:master Dec 25, 2023
20 checks passed
@MarijnS95 MarijnS95 deleted the egui-winit-handle-dedicated-cut-copy-paste-keys branch December 25, 2023 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
eframe Relates to epi and eframe egui egui-winit porblems related to winit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants