Using sauron with bevy for clipboard usage? #74
Answered
by
miketwenty1
miketwenty1
asked this question in
Q&A
-
I'm creating a bevy wasm game and I would like to write to the users clipboard. I've made this post about trying to use web-sys / Clipboard, but also see sauron has support for clipboard and this may make my life easier. I'm struggling to understand the lib.rs examples with the need for Is sauron a good choice for trying to achieve my goal of populating the users clipboard from the wasm/bevy game? |
Beta Was this translation helpful? Give feedback.
Answered by
miketwenty1
Dec 31, 2022
Replies: 1 comment
-
I solved my issue: use wasm_bindgen_futures::spawn_local;
let _task = spawn_local(async move {
let window = web_sys::window().expect("window"); // { obj: val };
let nav = window.navigator().clipboard();
match nav {
Some(a) => {
let p = a.write_text("please god work");
let result = wasm_bindgen_futures::JsFuture::from(p)
.await
.expect("clipboard populated");
info!("clippyboy worked");
}
None => {
warn!("failed to copy clippyboy");
}
};
}); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
miketwenty1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I solved my issue: