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 5f0ec02
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions crates/eframe/src/web/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,30 @@ 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.input.raw.events.push(egui::Event::Cut);
runner.needs_repaint.repaint_asap();
})?;
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.input.raw.events.push(egui::Event::Copy);
runner.needs_repaint.repaint_asap();
})?;
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 5f0ec02

Please sign in to comment.