egui icon indicating copy to clipboard operation
egui copied to clipboard

Ability to get image paste events

Open creikey opened this issue 3 years ago • 3 comments

Similar to #1167

Is your feature request related to a problem? Please describe. In some applications I want to develop I need to allow the user to paste images into the application.

Describe the solution you'd like There is https://docs.rs/egui/0.19.0/egui/enum.Event.html Paste(String), perhaps a PasteImage(Image) could be added as well

Describe alternatives you've considered n/a

Additional context From what I understand this would need to be added to winit and however egui does its web support, some advice on this would be helpful as I'm interested in implementing this feature myself

creikey avatar Oct 04 '22 22:10 creikey

https://crates.io/crates/clipboard-win it seems like this crate supports image copy paste on windows

creikey avatar Oct 04 '22 22:10 creikey

https://crates.io/crates/arboard also supports image copy/paste, and is cross-platform (except for web).

I think this could be added to egui and eframe with not too much effort. Unless you really need web support for images you can just not implement it there.

The way I would implement it is to make arboard and opt-in feature of eframe, and to add egui::Event::PasteImage(ColorImage) and PlatformOutput::copied_image: Option<ColorImage>.

emilk avatar Oct 07 '22 07:10 emilk

For eframe

Couldn't we get the images from https://github.com/emilk/egui/blob/f6fa74c66578be17c1a2a80eb33b1704f17a3d5f/crates/eframe/src/web/events.rs#L322-L323

// pseudo code
if data.types() == ["files"] {
   let file_list = data.files();
   let file = file_list.item(0).unwrap(); // to safe
   if file is image {
       let egui_event = egui::Event::PasteImage(file);
   }
}

Its-Just-Nans avatar Oct 24 '25 03:10 Its-Just-Nans