1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-30 21:30:03 -04:00

eframe web: Don't throw away frames on click/copy/cut (#3623)

* Follow-up to https://github.com/emilk/egui/pull/3621 and
https://github.com/emilk/egui/pull/3513

To work around a Safari limitation, we run the app logic in the event
handler of copy, cut, and mouse up and down.

Previously the output of that frame was discarded, but in this PR it is
now saved to be used in the next requestAnimationFrame.

The result is noticeable more distinct clicks on buttons (one more frame
of highlight)

Bonus: also fix auto-save of a sleeping web app
This commit is contained in:
Emil Ernerfeldt
2023-11-24 10:08:43 +01:00
committed by GitHub
parent 0d24a3a73b
commit 23732be0e5
5 changed files with 73 additions and 29 deletions

View File

@@ -49,6 +49,10 @@ use crate::Theme;
// ----------------------------------------------------------------------------
pub(crate) fn string_from_js_value(value: &JsValue) -> String {
value.as_string().unwrap_or_else(|| format!("{value:#?}"))
}
/// Current time in seconds (since undefined point in time).
///
/// Monotonically increasing.
@@ -196,7 +200,7 @@ fn set_clipboard_text(s: &str) {
let future = wasm_bindgen_futures::JsFuture::from(promise);
let future = async move {
if let Err(err) = future.await {
log::error!("Copy/cut action failed: {err:?}");
log::error!("Copy/cut action failed: {}", string_from_js_value(&err));
}
};
wasm_bindgen_futures::spawn_local(future);