Browse Source
Fix when a string containing CRLF is pasted from the clipboard (#826)
pull/831/head
sumibi-yakitori
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
8 additions and
2 deletions
-
egui-winit/src/lib.rs
-
egui_web/src/lib.rs
|
|
@ -490,7 +490,9 @@ impl State { |
|
|
|
self.egui_input.events.push(egui::Event::Copy); |
|
|
|
} else if is_paste_command(self.egui_input.modifiers, keycode) { |
|
|
|
if let Some(contents) = self.clipboard.get() { |
|
|
|
self.egui_input.events.push(egui::Event::Text(contents)); |
|
|
|
self.egui_input |
|
|
|
.events |
|
|
|
.push(egui::Event::Text(contents.replace("\r\n", "\n"))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
@ -642,7 +642,11 @@ fn install_document_events(runner_ref: &AppRunnerRef) -> Result<(), JsValue> { |
|
|
|
if let Some(data) = event.clipboard_data() { |
|
|
|
if let Ok(text) = data.get_data("text") { |
|
|
|
let mut runner_lock = runner_ref.0.lock(); |
|
|
|
runner_lock.input.raw.events.push(egui::Event::Text(text)); |
|
|
|
runner_lock |
|
|
|
.input |
|
|
|
.raw |
|
|
|
.events |
|
|
|
.push(egui::Event::Text(text.replace("\r\n", "\n"))); |
|
|
|
runner_lock.needs_repaint.set_true(); |
|
|
|
event.stop_propagation(); |
|
|
|
event.prevent_default(); |
|
|
|