Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clipboard not working #1

Open
cpt-n3mo opened this issue Feb 11, 2025 · 5 comments
Open

clipboard not working #1

cpt-n3mo opened this issue Feb 11, 2025 · 5 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@cpt-n3mo
Copy link

cpt-n3mo commented Feb 11, 2025

using latest dioxus
and latest dioxuss-clipboard

let mut cb = use_clipboard();
let a = cb.set("Something".to_string());

// result
assert_eq(Ok(()), a);
assert_eq(Ok("".to_string()). cb.get());

// expected
assert_eq(Ok(()),a);
assert_eq(Ok("Something".to_string()), cb.get())
@marc2332 marc2332 self-assigned this Feb 11, 2025
@marc2332 marc2332 added the help wanted Extra attention is needed label Feb 11, 2025
@marc2332
Copy link
Member

I am not sure if the clipboard is automatically written, that might make the get() method still give you an outdated value. Have you tried and then some time later reading it?

@cpt-n3mo
Copy link
Author

jup tried that as well..
but this seems to be a upstream problem,
i just tried this with copypasta and it does not work either on X11

@cpt-n3mo
Copy link
Author

cpt-n3mo commented Feb 11, 2025

Ok it seems that X11-clipboard that is used by copypasta which is used by use_clipboard only work server side
so this does not work inside of a component, only in a server function, and only for as long as the context lives. else clipboard will be blank

this might be something to add to the docs.

kind regards

@cpt-n3mo
Copy link
Author

using the web-sys crate one can use the clipboard inside a client side component.

let cb = web_sys::window().unwrap().navigator().clipboard();
cb.write_text("Working");

@marc2332
Copy link
Member

Ok it seems that X11-clipboard that is used by copypasta which is used by use_clipboard only work server side so this does not work inside of a component, only in a server function, and only for as long as the context lives. else clipboard will be blank

this might be something to add to the docs.

kind regards

It already says that only native renderers are supported https://github.com/dioxus-community/dioxus-clipboard?tab=readme-ov-file#support 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants