Skip to content

Commit

Permalink
Add some explanations for the safari copy/cut fix
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk committed Nov 21, 2023
1 parent a6da343 commit 8c68035
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/eframe/src/web/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ pub(crate) fn install_document_events(runner_ref: &WebRunner) -> Result<(), JsVa
"cut",
|event: web_sys::ClipboardEvent, runner| {
runner.input.raw.events.push(egui::Event::Cut);
runner.logic();
// In Safari we are only allowed to write to the clipboard during the
// event callback, which is why we run the app logic here and now:
runner.logic(); // we ignore the returned triangles, but schedule a repaint right after
runner.needs_repaint.repaint_asap();
event.stop_propagation();
event.prevent_default();
Expand All @@ -190,7 +192,9 @@ pub(crate) fn install_document_events(runner_ref: &WebRunner) -> Result<(), JsVa
"copy",
|event: web_sys::ClipboardEvent, runner| {
runner.input.raw.events.push(egui::Event::Copy);
runner.logic();
// In Safari we are only allowed to write to the clipboard during the
// event callback, which is why we run the app logic here and now:
runner.logic(); // we ignore the returned triangles, but schedule a repaint right after
runner.needs_repaint.repaint_asap();
event.stop_propagation();
event.prevent_default();
Expand Down

0 comments on commit 8c68035

Please sign in to comment.