Skip to content

Using set_text is not working when calling&creating Clipboard from other function #154

@ktwrd

Description

@ktwrd

When using a different function for handling the creation of Clipboard and usage of set_text, the clipboard content is not set.

use arboard::Clipboard;
use std::thread::sleep;
use core::time::Duration;
fn main() {
    let data = String::from("hello world");

    println!("before copy_text");
    copy_text(data);
    println!("after copy_text");

    let d = Duration::from_millis(2500);
    sleep(d);

    println!("exiting (after 2.5s)");
    std::process::exit(0);
    // clipboard content will NOT be "hello world"
}
fn copy_text(content: String) {
    let mut instance = Clipboard::new().unwrap();
    instance.set_text(&content).unwrap();
}

I do not want to put a sleep inside of copy_text since I want stuff to run instantly after that and only wait 2s before actually exiting the application.

Metadata

Metadata

Assignees

Labels

O-UNIXWork related to X11 or Wayland on UNIX platformsdocumentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions