Skip to content

Commit

Permalink
Fix click-to-copy on Safari (#3621)
Browse files Browse the repository at this point in the history
* Closes lampsitter/egui_commonmark#21

Follow-up to #3513

Safari only allows access to the clipboard as response to user action,
so we need to take an extra logic step right in the event handler.
  • Loading branch information
emilk authored Nov 24, 2023
1 parent 79a56b3 commit 0d24a3a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/eframe/src/web/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ pub(crate) fn install_canvas_events(runner_ref: &WebRunner) -> Result<(), JsValu
pressed: true,
modifiers,
});
// 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();
Expand Down Expand Up @@ -310,6 +313,9 @@ pub(crate) fn install_canvas_events(runner_ref: &WebRunner) -> Result<(), JsValu
pressed: false,
modifiers,
});
// 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();

text_agent::update_text_agent(runner);
Expand Down

0 comments on commit 0d24a3a

Please sign in to comment.