egui-winit: Don't consume clipboard shortcuts (#3812)
<!-- 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. * 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! --> This breaking change seems to have snuck in during #3649. Previously it would never consume these, today it consumes them unconditionally, and with this change it'll ~~only consume them if egui wants text input~~ never consume them. This is a blocker for updating our application, sadly :(
This commit is contained in:
parent
42013cd6c2
commit
221a77dd5b
|
|
@ -341,9 +341,10 @@ impl State {
|
|||
}
|
||||
}
|
||||
WindowEvent::KeyboardInput { event, .. } => {
|
||||
self.on_keyboard_input(event);
|
||||
|
||||
// When pressing the Tab key, egui focuses the first focusable element, hence Tab always consumes.
|
||||
let consumed = self.on_keyboard_input(event)
|
||||
|| self.egui_ctx.wants_keyboard_input()
|
||||
let consumed = self.egui_ctx.wants_keyboard_input()
|
||||
|| event.logical_key
|
||||
== winit::keyboard::Key::Named(winit::keyboard::NamedKey::Tab);
|
||||
EventResponse {
|
||||
|
|
@ -653,7 +654,7 @@ impl State {
|
|||
}
|
||||
}
|
||||
|
||||
fn on_keyboard_input(&mut self, event: &winit::event::KeyEvent) -> bool {
|
||||
fn on_keyboard_input(&mut self, event: &winit::event::KeyEvent) {
|
||||
let winit::event::KeyEvent {
|
||||
// Represents the position of a key independent of the currently active layout.
|
||||
//
|
||||
|
|
@ -702,10 +703,10 @@ impl State {
|
|||
if pressed {
|
||||
if is_cut_command(self.egui_input.modifiers, logical_key) {
|
||||
self.egui_input.events.push(egui::Event::Cut);
|
||||
return true;
|
||||
return;
|
||||
} else if is_copy_command(self.egui_input.modifiers, logical_key) {
|
||||
self.egui_input.events.push(egui::Event::Copy);
|
||||
return true;
|
||||
return;
|
||||
} else if is_paste_command(self.egui_input.modifiers, logical_key) {
|
||||
if let Some(contents) = self.clipboard.get() {
|
||||
let contents = contents.replace("\r\n", "\n");
|
||||
|
|
@ -713,7 +714,7 @@ impl State {
|
|||
self.egui_input.events.push(egui::Event::Paste(contents));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -744,8 +745,6 @@ impl State {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
/// Call with the output given by `egui`.
|
||||
|
|
|
|||
Loading…
Reference in New Issue