31 lines
836 B
Rust
31 lines
836 B
Rust
use window_clipboard::PlatformClipboard;
|
|
use winit::{
|
|
error::EventLoopError,
|
|
event::{Event, WindowEvent},
|
|
event_loop::EventLoop,
|
|
window::WindowBuilder,
|
|
};
|
|
|
|
fn main() -> Result<(), EventLoopError> {
|
|
let event_loop = EventLoop::new().unwrap();
|
|
|
|
let window = WindowBuilder::new()
|
|
.with_title("A fantastic window!")
|
|
.build(&event_loop)
|
|
.unwrap();
|
|
|
|
let mut clipboard = unsafe { PlatformClipboard::connect(&window) }
|
|
.expect("Connect to clipboard");
|
|
|
|
clipboard
|
|
.write(String::from("Hello, world!"))
|
|
.expect("Write to clipboard");
|
|
|
|
event_loop.run(move |event, elwt| match event {
|
|
Event::WindowEvent {
|
|
event: WindowEvent::CloseRequested,
|
|
window_id,
|
|
} if window_id == window.id() => elwt.exit(),
|
|
_ => {}
|
|
})
|
|
}
|