Skip to content

Commit

Permalink
fix emilk#3480 - copy doesn't work on Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
lunixbochs committed Oct 30, 2023
1 parent fd75adb commit 775e70b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions crates/eframe/src/web/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,21 @@ pub(crate) fn install_document_events(runner_ref: &WebRunner) -> Result<(), JsVa
)?;

#[cfg(web_sys_unstable_apis)]
runner_ref.add_event_listener(&document, "cut", |_: web_sys::ClipboardEvent, runner| {
runner_ref.add_event_listener(&document, "cut", |event: web_sys::ClipboardEvent, runner| {
runner.input.raw.events.push(egui::Event::Cut);
runner.logic();
runner.needs_repaint.repaint_asap();
event.stop_propagation();
event.prevent_default();
})?;

#[cfg(web_sys_unstable_apis)]
runner_ref.add_event_listener(&document, "copy", |_: web_sys::ClipboardEvent, runner| {
runner_ref.add_event_listener(&document, "copy", |event: web_sys::ClipboardEvent, runner| {
runner.input.raw.events.push(egui::Event::Copy);
runner.logic();
runner.needs_repaint.repaint_asap();
event.stop_propagation();
event.prevent_default();
})?;

Ok(())
Expand Down

0 comments on commit 775e70b

Please sign in to comment.